<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>http://project-au.w.kmwc.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Marie</id>
	<title>Project AU - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="http://project-au.w.kmwc.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Marie"/>
	<link rel="alternate" type="text/html" href="http://project-au.w.kmwc.org/w/Special:Contributions/Marie"/>
	<updated>2026-04-10T00:40:18Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.41.1</generator>
	<entry>
		<id>http://project-au.w.kmwc.org/index.php?title=Holy_Worlds_of_Heaven&amp;diff=2454</id>
		<title>Holy Worlds of Heaven</title>
		<link rel="alternate" type="text/html" href="http://project-au.w.kmwc.org/index.php?title=Holy_Worlds_of_Heaven&amp;diff=2454"/>
		<updated>2026-01-24T03:30:57Z</updated>

		<summary type="html">&lt;p&gt;Marie: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Infobox country&lt;br /&gt;
|conventional_long_name= Holy Worlds of Heaven under the Guidance of the Quorum and the Angel Moroni&lt;br /&gt;
|native_name= &lt;br /&gt;
|common_name=&lt;br /&gt;
|image_flag= HWHFlag.png&lt;br /&gt;
|image_symbol= &lt;br /&gt;
|symbol_type= &lt;br /&gt;
|symbol=&lt;br /&gt;
|capital_type= Capital world&lt;br /&gt;
|capital= [[Diddreta]]&lt;br /&gt;
|largest_settlement_type = &lt;br /&gt;
|largest_settlement = &lt;br /&gt;
|official_languages= [[Classical Diddretic language|Classical Diddretic]] &amp;lt;small&amp;gt;(de jure)&amp;lt;/small&amp;gt;&amp;lt;br&amp;gt;[[Contemporary Diddretic language|Diddretic]] &amp;lt;small&amp;gt;(de facto)&amp;lt;/small&amp;gt;&lt;br /&gt;
|government_type= Semi-constitutional theocratic elective monarchy&lt;br /&gt;
|leader_title1 = Prophet&lt;br /&gt;
|leader_name1 = ?&lt;br /&gt;
|leader_title2 = Archinquisitor &lt;br /&gt;
|leader_name2 = ?&lt;br /&gt;
|legislature = ?&lt;br /&gt;
|demonym= Deseretan&lt;br /&gt;
|upper_house= [[Quorum of the Twelve Apostles]]&lt;br /&gt;
|lower_house= [[Quorum of the Seventy]]&lt;br /&gt;
|currency=&lt;br /&gt;
}}&lt;/div&gt;</summary>
		<author><name>Marie</name></author>
	</entry>
	<entry>
		<id>http://project-au.w.kmwc.org/index.php?title=File:HWHFlag.png&amp;diff=2452</id>
		<title>File:HWHFlag.png</title>
		<link rel="alternate" type="text/html" href="http://project-au.w.kmwc.org/index.php?title=File:HWHFlag.png&amp;diff=2452"/>
		<updated>2026-01-24T03:29:29Z</updated>

		<summary type="html">&lt;p&gt;Marie: Marie moved page File:Image.png to File:HWHFlag.png&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Marie</name></author>
	</entry>
	<entry>
		<id>http://project-au.w.kmwc.org/index.php?title=File:HWHFlag.png&amp;diff=2451</id>
		<title>File:HWHFlag.png</title>
		<link rel="alternate" type="text/html" href="http://project-au.w.kmwc.org/index.php?title=File:HWHFlag.png&amp;diff=2451"/>
		<updated>2026-01-24T03:28:54Z</updated>

		<summary type="html">&lt;p&gt;Marie: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Marie</name></author>
	</entry>
	<entry>
		<id>http://project-au.w.kmwc.org/index.php?title=Holy_Worlds_of_Heaven&amp;diff=2450</id>
		<title>Holy Worlds of Heaven</title>
		<link rel="alternate" type="text/html" href="http://project-au.w.kmwc.org/index.php?title=Holy_Worlds_of_Heaven&amp;diff=2450"/>
		<updated>2026-01-23T22:50:46Z</updated>

		<summary type="html">&lt;p&gt;Marie: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Infobox country&lt;br /&gt;
|conventional_long_name= Holy Worlds of Heaven under the Guidance of the Quorum and the Angel Moroni&lt;br /&gt;
|native_name= &lt;br /&gt;
|common_name=&lt;br /&gt;
|image_symbol= &lt;br /&gt;
|symbol_type= &lt;br /&gt;
|symbol=&lt;br /&gt;
|capital_type= Capital world&lt;br /&gt;
|capital= [[Diddreta]]&lt;br /&gt;
|largest_settlement_type = &lt;br /&gt;
|largest_settlement = &lt;br /&gt;
|official_languages= [[Classical Diddretic language|Classical Diddretic]] &amp;lt;small&amp;gt;(de jure)&amp;lt;/small&amp;gt;&amp;lt;br&amp;gt;[[Contemporary Diddretic language|Diddretic]] &amp;lt;small&amp;gt;(de facto)&amp;lt;/small&amp;gt;&lt;br /&gt;
|government_type= Semi-constitutional theocratic elective monarchy&lt;br /&gt;
|leader_title1 = Prophet&lt;br /&gt;
|leader_name1 = ?&lt;br /&gt;
|leader_title2 = Archinquisitor &lt;br /&gt;
|leader_name2 = ?&lt;br /&gt;
|legislature = ?&lt;br /&gt;
|demonym= Deseretan&lt;br /&gt;
|upper_house= [[Quorum of the Twelve Apostles]]&lt;br /&gt;
|lower_house= [[Quorum of the Seventy]]&lt;br /&gt;
|currency=&lt;br /&gt;
}}&lt;/div&gt;</summary>
		<author><name>Marie</name></author>
	</entry>
	<entry>
		<id>http://project-au.w.kmwc.org/index.php?title=Holy_Worlds_of_Heaven&amp;diff=2449</id>
		<title>Holy Worlds of Heaven</title>
		<link rel="alternate" type="text/html" href="http://project-au.w.kmwc.org/index.php?title=Holy_Worlds_of_Heaven&amp;diff=2449"/>
		<updated>2026-01-23T22:50:32Z</updated>

		<summary type="html">&lt;p&gt;Marie: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Infobox country&lt;br /&gt;
|conventional_long_name= Holy Worlds of Heaven under the Guidance of the Quorum and the Angel Moroni&lt;br /&gt;
|native_name= &lt;br /&gt;
|common_name=&lt;br /&gt;
|image_symbol= &lt;br /&gt;
|symbol_type= &lt;br /&gt;
|symbol=&lt;br /&gt;
|capital_type= Capital world&lt;br /&gt;
|capital= [[Diddreta]]&lt;br /&gt;
|largest_settlement_type = &lt;br /&gt;
|largest_settlement = &lt;br /&gt;
|official_languages= [[Classical Diddretic language|Classical Diddretic]] &amp;lt;small&amp;gt;(de jure)&amp;lt;/small&amp;gt;&amp;lt;br&amp;gt;[[Contemporary Diddretic language|Diddretic]] &amp;lt;small&amp;gt;(de facto)&amp;lt;/small&amp;gt;&lt;br /&gt;
|government_type= Semi-constitutional theocratic elective monarchy&lt;br /&gt;
|leader_title1 = Prophet&lt;br /&gt;
|leader_name1 = ?&lt;br /&gt;
|leader_title2 = Archinquisitor &lt;br /&gt;
|leader_name2 = ?&lt;br /&gt;
|legislature =&lt;br /&gt;
|demonym= Deseretan&lt;br /&gt;
|upper_house= [[Quorum of the Twelve Apostles]]&lt;br /&gt;
|lower_house= [[Quorum of the Seventy]]&lt;br /&gt;
|currency=&lt;br /&gt;
}}&lt;/div&gt;</summary>
		<author><name>Marie</name></author>
	</entry>
	<entry>
		<id>http://project-au.w.kmwc.org/index.php?title=Holy_Worlds_of_Heaven&amp;diff=2439</id>
		<title>Holy Worlds of Heaven</title>
		<link rel="alternate" type="text/html" href="http://project-au.w.kmwc.org/index.php?title=Holy_Worlds_of_Heaven&amp;diff=2439"/>
		<updated>2026-01-22T23:33:45Z</updated>

		<summary type="html">&lt;p&gt;Marie: Created page with &amp;quot;{{Infobox country |conventional_long_name= Holy Worlds of Heaven under the Guidance of the Quorum and the Angel Moroni |native_name=  |common_name= |image_symbol=  |symbol_type=  |symbol= |capital_type= Capital world |capital= Diddreta |largest_settlement_type =  |largest_settlement =  |official_languages= Classical Diddretic &amp;lt;small&amp;gt;(de jure)&amp;lt;/small&amp;gt;&amp;lt;br&amp;gt;Diddretic &amp;lt;small&amp;gt;(de facto)&amp;lt;/small&amp;gt; |governmen...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Infobox country&lt;br /&gt;
|conventional_long_name= Holy Worlds of Heaven under the Guidance of the Quorum and the Angel Moroni&lt;br /&gt;
|native_name= &lt;br /&gt;
|common_name=&lt;br /&gt;
|image_symbol= &lt;br /&gt;
|symbol_type= &lt;br /&gt;
|symbol=&lt;br /&gt;
|capital_type= Capital world&lt;br /&gt;
|capital= [[Diddreta]]&lt;br /&gt;
|largest_settlement_type = &lt;br /&gt;
|largest_settlement = &lt;br /&gt;
|official_languages= [[Classical Diddretic language|Classical Diddretic]] &amp;lt;small&amp;gt;(de jure)&amp;lt;/small&amp;gt;&amp;lt;br&amp;gt;[[Contemporary Diddretic language|Diddretic]] &amp;lt;small&amp;gt;(de facto)&amp;lt;/small&amp;gt;&lt;br /&gt;
|government_type= Semi-constitutional theocratic elective monarchy&lt;br /&gt;
|demonym= Deseretan&lt;br /&gt;
|upper_house=&lt;br /&gt;
|lower_house=&lt;br /&gt;
|currency=&lt;br /&gt;
}}&lt;/div&gt;</summary>
		<author><name>Marie</name></author>
	</entry>
	<entry>
		<id>http://project-au.w.kmwc.org/index.php?title=Main_Page&amp;diff=2438</id>
		<title>Main Page</title>
		<link rel="alternate" type="text/html" href="http://project-au.w.kmwc.org/index.php?title=Main_Page&amp;diff=2438"/>
		<updated>2026-01-22T23:29:16Z</updated>

		<summary type="html">&lt;p&gt;Marie: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Front/banner}}__NOTOC__&lt;br /&gt;
{| class=&amp;quot;mp_content&amp;quot;&lt;br /&gt;
|class=&amp;quot;mp_left mp_box&amp;quot; rowspan=2| &amp;lt;div class=&amp;quot;mp_left_border mp_gradient_border&amp;quot;&amp;gt;&lt;br /&gt;
| class=&amp;quot;MainPageBG&amp;quot; style=&amp;quot;width:50%; border:3px solid #6190F4; background:#C5D4F7; vertical-align:top; color:#000;&amp;quot; |&lt;br /&gt;
{| id=&amp;quot;mp-left&amp;quot; style=&amp;quot;width:100%; vertical-align:top; background:#C5D4F7;&amp;quot;&lt;br /&gt;
| style=&amp;quot;padding:2px;&amp;quot; | &amp;lt;h2 id=&amp;quot;mp-tfa-h2&amp;quot; style=&amp;quot;margin:3px; background:#6190F4; font-size:120%; font-weight:bold; border:1px solid #00001F; text-align:left; color:#000; padding:0.2em 0.4em;&amp;quot;&amp;gt;What is Project AU?&amp;lt;/h2&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;color:#000;&amp;quot; | &amp;lt;div id=&amp;quot;mp-tfa&amp;quot; style=&amp;quot;padding:2px 5px&amp;quot;&amp;gt;content goes here&amp;lt;/div&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding:2px;&amp;quot; | &amp;lt;h2 id=&amp;quot;mp-dyk-h2&amp;quot; style=&amp;quot;margin:3px; background:#6190F4; font-size:120%; font-weight:bold; border:1px solid #00001F; text-align:left; color:#000; padding:0.2em 0.4em;&amp;quot;&amp;gt;Recent Changes&amp;lt;/h2&amp;gt;&lt;br /&gt;
{{Special:RecentChanges/20}}&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
| style=&amp;quot;border:1px solid transparent;&amp;quot; |&lt;br /&gt;
| class=&amp;quot;MainPageBG&amp;quot; style=&amp;quot;width:50%; border:3px solid #6190F4; background:#C5D4F7; vertical-align:top;&amp;quot;|&lt;br /&gt;
{| id=&amp;quot;mp-right&amp;quot; style=&amp;quot;width:100%; vertical-align:top; background:#C5D4F7;&amp;quot;&lt;br /&gt;
| style=&amp;quot;padding:2px;&amp;quot; | &amp;lt;h2 id=&amp;quot;mp-itn-h2&amp;quot; style=&amp;quot;margin:3px; background:#6190F4; font-size:120%; font-weight:bold; border:1px solid #00001F; text-align:left; color:#000; padding:0.2em 0.4em;&amp;quot;&amp;gt;History&amp;lt;/h2&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;color:#000; padding:2px 5px;&amp;quot; | &amp;lt;div id=&amp;quot;mp-itn&amp;quot;&amp;gt;content goes here&amp;lt;/div&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding:2px;&amp;quot; | &amp;lt;h2 id=&amp;quot;mp-otd-h2&amp;quot; style=&amp;quot;margin:3px; background:#6190F4; font-size:120%; font-weight:bold; border:1px solid #00001F; text-align:left; color:#000; padding:0.2em 0.4em;&amp;quot;&amp;gt;Nations&amp;lt;/h2&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;color:#000; padding:2px 5px 5px;&amp;quot; | &amp;lt;div id=&amp;quot;mp-otd&amp;quot;&amp;gt;[[Coalition of Allied Star Systems]] • [[Eternal Rulership of the Four Fortresses]] • [[Great Huai]] • [[Holy Worlds of Heaven]] • [[Holy Worlds under Gafua]] • [[Serene Union of the Tbeew Cluster]] • [[Star Union of Systems]] • [[United Astradom of Thynhe-Gyftpoul]]&amp;lt;/div&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding:2px;&amp;quot; | &amp;lt;h2 id=&amp;quot;mp-otd-h2&amp;quot; style=&amp;quot;margin:3px; background:#6190F4; font-size:120%; font-weight:bold; border:1px solid #00001F; text-align:left; color:#000; padding:0.2em 0.4em;&amp;quot;&amp;gt;Planets&amp;lt;/h2&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;color:#000; padding:2px 5px 5px;&amp;quot; | &amp;lt;div id=&amp;quot;mp-otd&amp;quot;&amp;gt;content goes here&amp;lt;/div&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Marie</name></author>
	</entry>
	<entry>
		<id>http://project-au.w.kmwc.org/index.php?title=Gregandupila&amp;diff=2115</id>
		<title>Gregandupila</title>
		<link rel="alternate" type="text/html" href="http://project-au.w.kmwc.org/index.php?title=Gregandupila&amp;diff=2115"/>
		<updated>2026-01-17T19:47:35Z</updated>

		<summary type="html">&lt;p&gt;Marie: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Taxobox&lt;br /&gt;
| name               = Gregandupila&lt;br /&gt;
| image              = Gregandupila scale.png&lt;br /&gt;
| image_upright      =&lt;br /&gt;
| image_alt          = &lt;br /&gt;
| image_caption      = Diagram showing the side of a Gregandupila, with a Human for comparison&lt;br /&gt;
| status             = LC&lt;br /&gt;
| colour_as          = Animalia&lt;br /&gt;
| regnum             = ?&lt;br /&gt;
| phylum             = ?&lt;br /&gt;
| classis            = ?&lt;br /&gt;
| superordo          = ?&lt;br /&gt;
| ordo               = ?&lt;br /&gt;
| superfamilia       = ?&lt;br /&gt;
| familia            = ?&lt;br /&gt;
| genus              = Gregandupila&lt;br /&gt;
| species            = &#039;&#039;&#039;?&#039;&#039;&#039;&lt;br /&gt;
| binomial           = &#039;&#039;Gregandupila ?&#039;&#039;&lt;br /&gt;
| binomial_authority = &lt;br /&gt;
| range_map          = &amp;lt;!--optional map—also range map2, 3 or 4 --&amp;gt;&lt;br /&gt;
| range_map_upright    = &lt;br /&gt;
| range map_alt      = &lt;br /&gt;
| range_map_caption  = &lt;br /&gt;
| status_system      = IUCN3.1&lt;br /&gt;
| &amp;lt;!--or 115 other parameters--&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;Gregandupilae&#039;&#039;&#039; are a sophont species within the [[Settled Systems]], originating from their home planet of [[Beautiful Eye]].&lt;br /&gt;
&lt;br /&gt;
[[Category:Biology]][[Category:Species]][[Category:Sophonts]]&lt;/div&gt;</summary>
		<author><name>Marie</name></author>
	</entry>
	<entry>
		<id>http://project-au.w.kmwc.org/index.php?title=Gregandupila&amp;diff=2108</id>
		<title>Gregandupila</title>
		<link rel="alternate" type="text/html" href="http://project-au.w.kmwc.org/index.php?title=Gregandupila&amp;diff=2108"/>
		<updated>2026-01-16T15:35:41Z</updated>

		<summary type="html">&lt;p&gt;Marie: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Taxobox&lt;br /&gt;
| name               = Gregandupila&lt;br /&gt;
| image              = Gregandupila scale.png&lt;br /&gt;
| image_upright      =&lt;br /&gt;
| image_alt          = &lt;br /&gt;
| image_caption      = Diagram showing the side of a Gregandupila, with a Human for comparison&lt;br /&gt;
| status             = LC&lt;br /&gt;
| colour_as          = Animalia&lt;br /&gt;
| regnum             = ?&lt;br /&gt;
| phylum             = ?&lt;br /&gt;
| classis            = ?&lt;br /&gt;
| superordo          = ?&lt;br /&gt;
| ordo               = ?&lt;br /&gt;
| superfamilia       = ?&lt;br /&gt;
| familia            = ?&lt;br /&gt;
| genus              = Gregandupila&lt;br /&gt;
| species            = &#039;&#039;&#039;?&#039;&#039;&#039;&lt;br /&gt;
| binomial           = &#039;&#039;Gregandupila ?&#039;&#039;&lt;br /&gt;
| binomial_authority = &lt;br /&gt;
| range_map          = &amp;lt;!--optional map—also range map2, 3 or 4 --&amp;gt;&lt;br /&gt;
| range_map_upright    = &lt;br /&gt;
| range map_alt      = &lt;br /&gt;
| range_map_caption  = &lt;br /&gt;
| status_system      = IUCN3.1&lt;br /&gt;
| &amp;lt;!--or 115 other parameters--&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Biology]][[Category:Sophonts]]&lt;/div&gt;</summary>
		<author><name>Marie</name></author>
	</entry>
	<entry>
		<id>http://project-au.w.kmwc.org/index.php?title=Gregandupila&amp;diff=2107</id>
		<title>Gregandupila</title>
		<link rel="alternate" type="text/html" href="http://project-au.w.kmwc.org/index.php?title=Gregandupila&amp;diff=2107"/>
		<updated>2026-01-16T15:33:44Z</updated>

		<summary type="html">&lt;p&gt;Marie: Created page with &amp;quot;{{Taxobox | name               = Gregandupila | image              = Gregandupila scale.png | image_upright      = | image_alt          =  | image_caption      = Diagram showing the side of a Gregandupila, with a Human for comparison | status             = LC | colour_as          = Animalia | regnum             = ? | phylum             = ? | classis            = ? | superordo          = ? | ordo               = ? | superfamilia       = ? | familia            = ? | genus...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Taxobox&lt;br /&gt;
| name               = Gregandupila&lt;br /&gt;
| image              = Gregandupila scale.png&lt;br /&gt;
| image_upright      =&lt;br /&gt;
| image_alt          = &lt;br /&gt;
| image_caption      = Diagram showing the side of a Gregandupila, with a Human for comparison&lt;br /&gt;
| status             = LC&lt;br /&gt;
| colour_as          = Animalia&lt;br /&gt;
| regnum             = ?&lt;br /&gt;
| phylum             = ?&lt;br /&gt;
| classis            = ?&lt;br /&gt;
| superordo          = ?&lt;br /&gt;
| ordo               = ?&lt;br /&gt;
| superfamilia       = ?&lt;br /&gt;
| familia            = ?&lt;br /&gt;
| genus              = Gregandupila&lt;br /&gt;
| species            = &#039;&#039;&#039;?&#039;&#039;&#039;&lt;br /&gt;
| binomial           = &#039;&#039;Gregandupila ?&#039;&#039;&lt;br /&gt;
| binomial_authority = &lt;br /&gt;
| range_map          = &amp;lt;!--optional map—also range map2, 3 or 4 --&amp;gt;&lt;br /&gt;
| range_map_upright    = &lt;br /&gt;
| range map_alt      = &lt;br /&gt;
| range_map_caption  = &lt;br /&gt;
| status_system      = IUCN3.1&lt;br /&gt;
| &amp;lt;!--or 115 other parameters--&amp;gt;&lt;br /&gt;
}}&lt;/div&gt;</summary>
		<author><name>Marie</name></author>
	</entry>
	<entry>
		<id>http://project-au.w.kmwc.org/index.php?title=File:Gregandupila_scale.png&amp;diff=2106</id>
		<title>File:Gregandupila scale.png</title>
		<link rel="alternate" type="text/html" href="http://project-au.w.kmwc.org/index.php?title=File:Gregandupila_scale.png&amp;diff=2106"/>
		<updated>2026-01-16T15:33:10Z</updated>

		<summary type="html">&lt;p&gt;Marie: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Marie</name></author>
	</entry>
	<entry>
		<id>http://project-au.w.kmwc.org/index.php?title=He%C3%A9q%CA%BCb&amp;diff=2102</id>
		<title>Heéqʼb</title>
		<link rel="alternate" type="text/html" href="http://project-au.w.kmwc.org/index.php?title=He%C3%A9q%CA%BCb&amp;diff=2102"/>
		<updated>2026-01-16T12:34:48Z</updated>

		<summary type="html">&lt;p&gt;Marie: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Infobox planet&lt;br /&gt;
|name         = Heéqʼb&lt;br /&gt;
|image        = Heéqʼb.png&lt;br /&gt;
|alt          =&lt;br /&gt;
|caption      = Heéqʼb from orbit&lt;br /&gt;
|designation  = Wä́mth II&lt;br /&gt;
|satellites   = ?&lt;br /&gt;
|semimajor    = &lt;br /&gt;
|diameter     = 18049.52 km&amp;lt;br&amp;gt;(1.417 earth radii)&lt;br /&gt;
|year_length  = 41.5 earth days&lt;br /&gt;
|day_length   = 41.5 earth days&amp;lt;br/&amp;gt;&amp;lt;small&amp;gt;(995h 52m 32s) (spin-orbit locked)&amp;lt;/small&amp;gt;&lt;br /&gt;
|gravity      = 1.904 g&lt;br /&gt;
|axial_tilt   = 0°&lt;br /&gt;
|temperature  = X°C (Y°F)&lt;br /&gt;
|atmosphere   = &lt;br /&gt;
 {{unbulleted list |class=nowrap&lt;br /&gt;
  | 72.05% nitrogen (N&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt;)&lt;br /&gt;
  | 10.95% oxygen (O&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt;)&lt;br /&gt;
  | 0.003% carbon dioxide (CO&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt;)&lt;br /&gt;
  | 16% other (Ne, Ar, So&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt;)&lt;br /&gt;
 }}&lt;br /&gt;
|adjective    = Heeqid&lt;br /&gt;
|population   = 1,301,600,631&lt;br /&gt;
|jurisdiction = [[Eternal Rulership of the Four Fortresses]]&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Heéqʼb&#039;&#039;&#039; is the largest planet by population under the [[Eternal Rulership of the Four Fortresses]], and the homeworld of the [[Tetropsid|Tetropsid species]].&lt;br /&gt;
&lt;br /&gt;
[[Category:Planets]]&lt;/div&gt;</summary>
		<author><name>Marie</name></author>
	</entry>
	<entry>
		<id>http://project-au.w.kmwc.org/index.php?title=He%C3%A9q%CA%BCb&amp;diff=2101</id>
		<title>Heéqʼb</title>
		<link rel="alternate" type="text/html" href="http://project-au.w.kmwc.org/index.php?title=He%C3%A9q%CA%BCb&amp;diff=2101"/>
		<updated>2026-01-16T12:34:40Z</updated>

		<summary type="html">&lt;p&gt;Marie: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Infobox planet&lt;br /&gt;
|name         = Heéqʼb&lt;br /&gt;
|image        = Heéqʼb.png&lt;br /&gt;
|alt          =&lt;br /&gt;
|caption      = Heéqʼb from orbit&lt;br /&gt;
|designation  = Wä́mth II&lt;br /&gt;
|satellites   = ?&lt;br /&gt;
|semimajor    = &lt;br /&gt;
|diameter     = 18049.52 km&amp;lt;br&amp;gt;(1.417 earth radii)&lt;br /&gt;
|year_length  = 41.5 earth days&lt;br /&gt;
|day_length   = 41.5 earth days&amp;lt;br/&amp;gt;&amp;lt;small&amp;gt;(995h 52m 32s) (spin-orbit locked)&amp;lt;/small&amp;gt;&lt;br /&gt;
|gravity      = 1.904 g&lt;br /&gt;
|axial_tilt   = 0°&lt;br /&gt;
|temperature  = X°C (Y°F)&lt;br /&gt;
|atmosphere   = &lt;br /&gt;
 {{unbulleted list |class=nowrap&lt;br /&gt;
  | 72.05% nitrogen (N&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt;)&lt;br /&gt;
  | 10.95% oxygen (O&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt;)&lt;br /&gt;
  | 0.003% carbon dioxide (CO&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt;)&lt;br /&gt;
  | 16% other (Ne, Ar, So&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt;)&lt;br /&gt;
 }}&lt;br /&gt;
|adjective    = Heeqid&lt;br /&gt;
|population   = 1,301,600,631&lt;br /&gt;
|jurisdiction = [[Eternal Rulership of the Four Fortresses]]&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Heéqʼb&#039;&#039;&#039; is the largest planet by population under the [[Eternal Rulership of the Four Fortresses]], and the homeworld of the [[Tetropsids|Tetropsid species]].&lt;br /&gt;
&lt;br /&gt;
[[Category:Planets]]&lt;/div&gt;</summary>
		<author><name>Marie</name></author>
	</entry>
	<entry>
		<id>http://project-au.w.kmwc.org/index.php?title=He%C3%A9q%CA%BCb&amp;diff=2100</id>
		<title>Heéqʼb</title>
		<link rel="alternate" type="text/html" href="http://project-au.w.kmwc.org/index.php?title=He%C3%A9q%CA%BCb&amp;diff=2100"/>
		<updated>2026-01-16T12:34:29Z</updated>

		<summary type="html">&lt;p&gt;Marie: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Infobox planet&lt;br /&gt;
|name         = Heéqʼb&lt;br /&gt;
|image        = Heéqʼb.png&lt;br /&gt;
|alt          =&lt;br /&gt;
|caption      = Heéqʼb from orbit&lt;br /&gt;
|designation  = Wä́mth II&lt;br /&gt;
|satellites   = ?&lt;br /&gt;
|semimajor    = &lt;br /&gt;
|diameter     = 18049.52 km&amp;lt;br&amp;gt;(1.417 earth radii)&lt;br /&gt;
|year_length  = 41.5 earth days&lt;br /&gt;
|day_length   = 41.5 earth days&amp;lt;br/&amp;gt;&amp;lt;small&amp;gt;(995h 52m 32s) (spin-orbit locked)&amp;lt;/small&amp;gt;&lt;br /&gt;
|gravity      = 1.904 g&lt;br /&gt;
|axial_tilt   = 0°&lt;br /&gt;
|temperature  = X°C (Y°F)&lt;br /&gt;
|atmosphere   = &lt;br /&gt;
 {{unbulleted list |class=nowrap&lt;br /&gt;
  | 72.05% nitrogen (N&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt;)&lt;br /&gt;
  | 10.95% oxygen (O&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt;)&lt;br /&gt;
  | 0.003% carbon dioxide (CO&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt;)&lt;br /&gt;
  | 16% other (Ne, Ar, So&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt;)&lt;br /&gt;
 }}&lt;br /&gt;
|adjective    = Heeqid&lt;br /&gt;
|population   = 1,301,600,631&lt;br /&gt;
|jurisdiction = [[Eternal Rulership of the Four Fortresses]]&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Heéqʼb&#039;&#039;&#039; is the largest planet by population under the [[Eternal Rulership of the Four Fortresses]], and the homeworld of the [[Tetrospids|Tetropsid species]].&lt;br /&gt;
&lt;br /&gt;
[[Category:Planets]]&lt;/div&gt;</summary>
		<author><name>Marie</name></author>
	</entry>
	<entry>
		<id>http://project-au.w.kmwc.org/index.php?title=He%C3%A9q%CA%BCb&amp;diff=2099</id>
		<title>Heéqʼb</title>
		<link rel="alternate" type="text/html" href="http://project-au.w.kmwc.org/index.php?title=He%C3%A9q%CA%BCb&amp;diff=2099"/>
		<updated>2026-01-16T12:31:05Z</updated>

		<summary type="html">&lt;p&gt;Marie: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Infobox planet&lt;br /&gt;
|name         = Heéqʼb&lt;br /&gt;
|image        = Heéqʼb.png&lt;br /&gt;
|alt          =&lt;br /&gt;
|caption      = Heéqʼb from orbit&lt;br /&gt;
|designation  = Wä́mth II&lt;br /&gt;
|satellites   = ?&lt;br /&gt;
|semimajor    = &lt;br /&gt;
|diameter     = 18049.52 km&amp;lt;br&amp;gt;(1.417 earth radii)&lt;br /&gt;
|year_length  = 41.5 earth days&lt;br /&gt;
|day_length   = 41.5 earth days&amp;lt;br/&amp;gt;&amp;lt;small&amp;gt;(995h 52m 32s) (spin-orbit locked)&amp;lt;/small&amp;gt;&lt;br /&gt;
|gravity      = 1.904 g&lt;br /&gt;
|axial_tilt   = 0°&lt;br /&gt;
|temperature  = X°C (Y°F)&lt;br /&gt;
|atmosphere   = &lt;br /&gt;
 {{unbulleted list |class=nowrap&lt;br /&gt;
  | 72.05% nitrogen (N&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt;)&lt;br /&gt;
  | 10.95% oxygen (O&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt;)&lt;br /&gt;
  | 0.003% carbon dioxide (CO&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt;)&lt;br /&gt;
  | 16% other (Ne, Ar, So&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt;)&lt;br /&gt;
 }}&lt;br /&gt;
|adjective    = Heeqid&lt;br /&gt;
|population   = 1,301,600,631&lt;br /&gt;
|jurisdiction = [[Eternal Rulership of the Four Fortresses]]&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Heéqʼb&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
[[Category:Planets]]&lt;/div&gt;</summary>
		<author><name>Marie</name></author>
	</entry>
	<entry>
		<id>http://project-au.w.kmwc.org/index.php?title=He%C3%A9q%CA%BCb&amp;diff=2098</id>
		<title>Heéqʼb</title>
		<link rel="alternate" type="text/html" href="http://project-au.w.kmwc.org/index.php?title=He%C3%A9q%CA%BCb&amp;diff=2098"/>
		<updated>2026-01-16T12:30:45Z</updated>

		<summary type="html">&lt;p&gt;Marie: Created page with &amp;quot;{{Infobox planet |name         = Heéqʼb |image        = Heéqʼb.png |alt          = |caption      = Heéqʼb from orbit |designation  = Wä́mth II |satellites   = ? |semimajor    =  |diameter     = 18049.52 km&amp;lt;br&amp;gt;(1.417 earth radii) |year_length  = 41.5 earth days |day_length   = 41.5 earth days&amp;lt;br/&amp;gt;&amp;lt;small&amp;gt;(995h 52m 32s)(spin-orbit locked)&amp;lt;/small&amp;gt; |gravity      = 1.904 g |axial_tilt   = 0° |temperature  = X°C (Y°F) |atmosphere   =   {{unbulleted list |class=nowrap...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Infobox planet&lt;br /&gt;
|name         = Heéqʼb&lt;br /&gt;
|image        = Heéqʼb.png&lt;br /&gt;
|alt          =&lt;br /&gt;
|caption      = Heéqʼb from orbit&lt;br /&gt;
|designation  = Wä́mth II&lt;br /&gt;
|satellites   = ?&lt;br /&gt;
|semimajor    = &lt;br /&gt;
|diameter     = 18049.52 km&amp;lt;br&amp;gt;(1.417 earth radii)&lt;br /&gt;
|year_length  = 41.5 earth days&lt;br /&gt;
|day_length   = 41.5 earth days&amp;lt;br/&amp;gt;&amp;lt;small&amp;gt;(995h 52m 32s)(spin-orbit locked)&amp;lt;/small&amp;gt;&lt;br /&gt;
|gravity      = 1.904 g&lt;br /&gt;
|axial_tilt   = 0°&lt;br /&gt;
|temperature  = X°C (Y°F)&lt;br /&gt;
|atmosphere   = &lt;br /&gt;
 {{unbulleted list |class=nowrap&lt;br /&gt;
  | 72.05% nitrogen (N&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt;)&lt;br /&gt;
  | 10.95% oxygen (O&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt;)&lt;br /&gt;
  | 0.003% carbon dioxide (CO&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt;)&lt;br /&gt;
  | 16% other (Ne, Ar, So&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt;)&lt;br /&gt;
 }}&lt;br /&gt;
|adjective    = Heeqid&lt;br /&gt;
|population   = 1,301,600,631&lt;br /&gt;
|jurisdiction = [[Eternal Rulership of the Four Fortresses]]&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Heéqʼb&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
[[Category:Planets]]&lt;/div&gt;</summary>
		<author><name>Marie</name></author>
	</entry>
	<entry>
		<id>http://project-au.w.kmwc.org/index.php?title=File:He%C3%A9q%CA%BCb.png&amp;diff=2097</id>
		<title>File:Heéqʼb.png</title>
		<link rel="alternate" type="text/html" href="http://project-au.w.kmwc.org/index.php?title=File:He%C3%A9q%CA%BCb.png&amp;diff=2097"/>
		<updated>2026-01-16T12:22:35Z</updated>

		<summary type="html">&lt;p&gt;Marie: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Marie</name></author>
	</entry>
	<entry>
		<id>http://project-au.w.kmwc.org/index.php?title=Module:Coordinates&amp;diff=2095</id>
		<title>Module:Coordinates</title>
		<link rel="alternate" type="text/html" href="http://project-au.w.kmwc.org/index.php?title=Module:Coordinates&amp;diff=2095"/>
		<updated>2026-01-16T10:08:54Z</updated>

		<summary type="html">&lt;p&gt;Marie: 1 revision imported&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;--[[&lt;br /&gt;
This module is intended to replace the functionality of {{Coord}} and related&lt;br /&gt;
templates.  It provides several methods, including&lt;br /&gt;
&lt;br /&gt;
{{#invoke:Coordinates | coord }} : General function formatting and displaying&lt;br /&gt;
coordinate values.&lt;br /&gt;
&lt;br /&gt;
{{#invoke:Coordinates | dec2dms }} : Simple function for converting decimal&lt;br /&gt;
degree values to DMS format.&lt;br /&gt;
&lt;br /&gt;
{{#invoke:Coordinates | dms2dec }} : Simple function for converting DMS format&lt;br /&gt;
to decimal degree format.&lt;br /&gt;
&lt;br /&gt;
{{#invoke:Coordinates | link }} : Export the link used to reach the tools&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
require(&#039;strict&#039;)&lt;br /&gt;
&lt;br /&gt;
local math_mod = require(&amp;quot;Module:Math&amp;quot;)&lt;br /&gt;
local coordinates = {};&lt;br /&gt;
local isSandbox = mw.getCurrentFrame():getTitle():find(&#039;sandbox&#039;, 1, true);&lt;br /&gt;
&lt;br /&gt;
local current_page = mw.title.getCurrentTitle()&lt;br /&gt;
local page_name = mw.uri.encode( current_page.prefixedText, &#039;WIKI&#039; );&lt;br /&gt;
local coord_link = &#039;https://geohack.toolforge.org/geohack.php?pagename=&#039; .. page_name .. &#039;&amp;amp;params=&#039;&lt;br /&gt;
&lt;br /&gt;
--[[ Helper function, replacement for {{coord/display/title}} ]]&lt;br /&gt;
local function displaytitle(coords)&lt;br /&gt;
	return mw.getCurrentFrame():extensionTag{&lt;br /&gt;
		name = &#039;indicator&#039;,&lt;br /&gt;
		args = { name = &#039;coordinates&#039; },&lt;br /&gt;
		content = &#039;&amp;lt;span id=&amp;quot;coordinates&amp;quot;&amp;gt;[[Geographic coordinate system|Coordinates]]: &#039; .. coords .. &#039;&amp;lt;/span&amp;gt;&#039;&lt;br /&gt;
	}&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--[[ Helper function, used in detecting DMS formatting ]]&lt;br /&gt;
local function dmsTest(first, second)&lt;br /&gt;
	if type(first) ~= &#039;string&#039; or type(second) ~= &#039;string&#039; then&lt;br /&gt;
		return nil&lt;br /&gt;
	end&lt;br /&gt;
	local s = (first .. second):upper()&lt;br /&gt;
	return s:find(&#039;^[NS][EW]$&#039;) or s:find(&#039;^[EW][NS]$&#039;)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[ Wrapper function to grab args, see Module:Arguments for this function&#039;s documentation. ]]&lt;br /&gt;
local function makeInvokeFunc(funcName)&lt;br /&gt;
	return function (frame)&lt;br /&gt;
		local args = require(&#039;Module:Arguments&#039;).getArgs(frame, {&lt;br /&gt;
			wrappers = &#039;Template:Coord&#039;&lt;br /&gt;
		})&lt;br /&gt;
		return coordinates[funcName](args, frame)&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--[[ Helper function, handle optional args. ]]&lt;br /&gt;
local function optionalArg(arg, supplement)&lt;br /&gt;
	return arg and arg .. supplement or &#039;&#039;&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--[[&lt;br /&gt;
Formats any error messages generated for display&lt;br /&gt;
]]&lt;br /&gt;
local function errorPrinter(errors)&lt;br /&gt;
	local result = &amp;quot;&amp;quot;&lt;br /&gt;
	for i,v in ipairs(errors) do&lt;br /&gt;
		result = result .. &#039;&amp;lt;strong class=&amp;quot;error&amp;quot;&amp;gt;Coordinates: &#039; .. v[2] .. &#039;&amp;lt;/strong&amp;gt;&amp;lt;br /&amp;gt;&#039;&lt;br /&gt;
	end&lt;br /&gt;
	return result&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--[[&lt;br /&gt;
Determine the required CSS class to display coordinates&lt;br /&gt;
&lt;br /&gt;
Usually geo-nondefault is hidden by CSS, unless a user has overridden this for himself&lt;br /&gt;
default is the mode as specificied by the user when calling the {{coord}} template&lt;br /&gt;
mode is the display mode (dec or dms) that we will need to determine the css class for&lt;br /&gt;
]]&lt;br /&gt;
local function displayDefault(default, mode)&lt;br /&gt;
	if default == &amp;quot;&amp;quot; then&lt;br /&gt;
		default = &amp;quot;dec&amp;quot;&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	if default == mode then&lt;br /&gt;
		return &amp;quot;geo-default&amp;quot;&lt;br /&gt;
	else&lt;br /&gt;
		return &amp;quot;geo-nondefault&amp;quot;&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--[[&lt;br /&gt;
specPrinter&lt;br /&gt;
&lt;br /&gt;
Output formatter.  Takes the structure generated by either parseDec&lt;br /&gt;
or parseDMS and formats it for inclusion on Wikipedia.&lt;br /&gt;
]]&lt;br /&gt;
local function specPrinter(args, coordinateSpec)&lt;br /&gt;
	local uriComponents = coordinateSpec[&amp;quot;param&amp;quot;]&lt;br /&gt;
	if uriComponents == &amp;quot;&amp;quot; then&lt;br /&gt;
		-- RETURN error, should never be empty or nil&lt;br /&gt;
		return &amp;quot;ERROR param was empty&amp;quot;&lt;br /&gt;
	end&lt;br /&gt;
	if args[&amp;quot;name&amp;quot;] then&lt;br /&gt;
		uriComponents = uriComponents .. &amp;quot;&amp;amp;title=&amp;quot; .. mw.uri.encode(coordinateSpec[&amp;quot;name&amp;quot;])&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	local geodmshtml = &#039;&amp;lt;span class=&amp;quot;geo-dms&amp;quot; title=&amp;quot;Maps, aerial photos, and other data for this location&amp;quot;&amp;gt;&#039;&lt;br /&gt;
			.. &#039;&amp;lt;span class=&amp;quot;latitude&amp;quot;&amp;gt;&#039; .. coordinateSpec[&amp;quot;dms-lat&amp;quot;] .. &#039;&amp;lt;/span&amp;gt; &#039;&lt;br /&gt;
			.. &#039;&amp;lt;span class=&amp;quot;longitude&amp;quot;&amp;gt;&#039; ..coordinateSpec[&amp;quot;dms-long&amp;quot;] .. &#039;&amp;lt;/span&amp;gt;&#039;&lt;br /&gt;
			.. &#039;&amp;lt;/span&amp;gt;&#039;&lt;br /&gt;
&lt;br /&gt;
	local lat = tonumber( coordinateSpec[&amp;quot;dec-lat&amp;quot;] ) or 0&lt;br /&gt;
	local geodeclat&lt;br /&gt;
	if lat &amp;lt; 0 then&lt;br /&gt;
		-- FIXME this breaks the pre-existing precision&lt;br /&gt;
		geodeclat = tostring(coordinateSpec[&amp;quot;dec-lat&amp;quot;]):sub(2) .. &amp;quot;°S&amp;quot;&lt;br /&gt;
	else&lt;br /&gt;
		geodeclat = (coordinateSpec[&amp;quot;dec-lat&amp;quot;] or 0) .. &amp;quot;°N&amp;quot;&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	local long = tonumber( coordinateSpec[&amp;quot;dec-long&amp;quot;] ) or 0&lt;br /&gt;
	local geodeclong&lt;br /&gt;
	if long &amp;lt; 0 then&lt;br /&gt;
		-- FIXME does not handle unicode minus&lt;br /&gt;
		geodeclong = tostring(coordinateSpec[&amp;quot;dec-long&amp;quot;]):sub(2) .. &amp;quot;°W&amp;quot;&lt;br /&gt;
	else&lt;br /&gt;
		geodeclong = (coordinateSpec[&amp;quot;dec-long&amp;quot;] or 0) .. &amp;quot;°E&amp;quot;&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	local geodechtml = &#039;&amp;lt;span class=&amp;quot;geo-dec&amp;quot; title=&amp;quot;Maps, aerial photos, and other data for this location&amp;quot;&amp;gt;&#039;&lt;br /&gt;
			.. geodeclat .. &#039; &#039;&lt;br /&gt;
			.. geodeclong&lt;br /&gt;
			.. &#039;&amp;lt;/span&amp;gt;&#039;&lt;br /&gt;
&lt;br /&gt;
	local geonumhtml = &#039;&amp;lt;span class=&amp;quot;geo&amp;quot;&amp;gt;&#039;&lt;br /&gt;
			.. coordinateSpec[&amp;quot;dec-lat&amp;quot;] .. &#039;; &#039;&lt;br /&gt;
			.. coordinateSpec[&amp;quot;dec-long&amp;quot;]&lt;br /&gt;
			.. &#039;&amp;lt;/span&amp;gt;&#039;&lt;br /&gt;
&lt;br /&gt;
	local inner = &#039;&amp;lt;span class=&amp;quot;&#039; .. displayDefault(coordinateSpec[&amp;quot;default&amp;quot;], &amp;quot;dms&amp;quot; ) .. &#039;&amp;quot;&amp;gt;&#039; .. geodmshtml .. &#039;&amp;lt;/span&amp;gt;&#039;&lt;br /&gt;
				.. &#039;&amp;lt;span class=&amp;quot;geo-multi-punct&amp;quot;&amp;gt;&amp;amp;#xfeff; / &amp;amp;#xfeff;&amp;lt;/span&amp;gt;&#039;&lt;br /&gt;
				.. &#039;&amp;lt;span class=&amp;quot;&#039; .. displayDefault(coordinateSpec[&amp;quot;default&amp;quot;], &amp;quot;dec&amp;quot; ) .. &#039;&amp;quot;&amp;gt;&#039;;&lt;br /&gt;
&lt;br /&gt;
	if not args[&amp;quot;name&amp;quot;] then&lt;br /&gt;
		inner = inner .. geodechtml&lt;br /&gt;
				.. &#039;&amp;lt;span style=&amp;quot;display:none&amp;quot;&amp;gt;&amp;amp;#xfeff; / &#039; .. geonumhtml .. &#039;&amp;lt;/span&amp;gt;&amp;lt;/span&amp;gt;&#039;&lt;br /&gt;
	else&lt;br /&gt;
		inner = inner .. &#039;&amp;lt;span class=&amp;quot;vcard&amp;quot;&amp;gt;&#039; .. geodechtml&lt;br /&gt;
				.. &#039;&amp;lt;span style=&amp;quot;display:none&amp;quot;&amp;gt;&amp;amp;#xfeff; / &#039; .. geonumhtml .. &#039;&amp;lt;/span&amp;gt;&#039;&lt;br /&gt;
				.. &#039;&amp;lt;span style=&amp;quot;display:none&amp;quot;&amp;gt;&amp;amp;#xfeff; (&amp;lt;span class=&amp;quot;fn org&amp;quot;&amp;gt;&#039;&lt;br /&gt;
				.. args[&amp;quot;name&amp;quot;] .. &#039;&amp;lt;/span&amp;gt;)&amp;lt;/span&amp;gt;&amp;lt;/span&amp;gt;&amp;lt;/span&amp;gt;&#039;&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
    local stylesheetLink = &#039;Module:Coordinates&#039; .. ( isSandbox and &#039;/sandbox&#039; or &#039;&#039; ) .. &#039;/styles.css&#039;&lt;br /&gt;
	return mw.getCurrentFrame():extensionTag{&lt;br /&gt;
		name = &#039;templatestyles&#039;, args = { src = stylesheetLink }&lt;br /&gt;
	} .. &#039;&amp;lt;span class=&amp;quot;plainlinks nourlexpansion&amp;quot;&amp;gt;[&#039; .. coord_link .. uriComponents ..&lt;br /&gt;
	&#039; &#039; .. inner .. &#039;]&amp;lt;/span&amp;gt;&#039; .. &#039;[[Category:Pages using gadget WikiMiniAtlas]]&#039;&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--[[ Helper function, convert decimal to degrees ]]&lt;br /&gt;
local function convert_dec2dms_d(coordinate)&lt;br /&gt;
	local d = math_mod._round( coordinate, 0 ) .. &amp;quot;°&amp;quot;&lt;br /&gt;
	return d .. &amp;quot;&amp;quot;&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--[[ Helper function, convert decimal to degrees and minutes ]]&lt;br /&gt;
local function convert_dec2dms_dm(coordinate)&lt;br /&gt;
	coordinate = math_mod._round( coordinate * 60, 0 );&lt;br /&gt;
	local m = coordinate % 60;&lt;br /&gt;
	coordinate = math.floor( (coordinate - m) / 60 );&lt;br /&gt;
	local d = coordinate % 360 ..&amp;quot;°&amp;quot;&lt;br /&gt;
&lt;br /&gt;
	return d .. string.format( &amp;quot;%02d′&amp;quot;, m )&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--[[ Helper function, convert decimal to degrees, minutes, and seconds ]]&lt;br /&gt;
local function convert_dec2dms_dms(coordinate)&lt;br /&gt;
	coordinate = math_mod._round( coordinate * 60 * 60, 0 );&lt;br /&gt;
	local s = coordinate % 60&lt;br /&gt;
	coordinate = math.floor( (coordinate - s) / 60 );&lt;br /&gt;
	local m = coordinate % 60&lt;br /&gt;
	coordinate = math.floor( (coordinate - m) / 60 );&lt;br /&gt;
	local d = coordinate % 360 ..&amp;quot;°&amp;quot;&lt;br /&gt;
&lt;br /&gt;
	return d .. string.format( &amp;quot;%02d′&amp;quot;, m ) .. string.format( &amp;quot;%02d″&amp;quot;, s )&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--[[&lt;br /&gt;
Helper function, convert decimal latitude or longitude to&lt;br /&gt;
degrees, minutes, and seconds format based on the specified precision.&lt;br /&gt;
]]&lt;br /&gt;
local function convert_dec2dms(coordinate, firstPostfix, secondPostfix, precision)&lt;br /&gt;
	local coord = tonumber(coordinate)&lt;br /&gt;
	local postfix&lt;br /&gt;
	if coord &amp;gt;= 0 then&lt;br /&gt;
		postfix = firstPostfix&lt;br /&gt;
	else&lt;br /&gt;
		postfix = secondPostfix&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	precision = precision:lower();&lt;br /&gt;
	if precision == &amp;quot;dms&amp;quot; then&lt;br /&gt;
		return convert_dec2dms_dms( math.abs( coord ) ) .. postfix;&lt;br /&gt;
	elseif precision == &amp;quot;dm&amp;quot; then&lt;br /&gt;
		return convert_dec2dms_dm( math.abs( coord ) ) .. postfix;&lt;br /&gt;
	elseif precision == &amp;quot;d&amp;quot; then&lt;br /&gt;
		return convert_dec2dms_d( math.abs( coord ) ) .. postfix;&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--[[&lt;br /&gt;
Convert DMS format into a N or E decimal coordinate&lt;br /&gt;
]]&lt;br /&gt;
local function convert_dms2dec(direction, degrees_str, minutes_str, seconds_str)&lt;br /&gt;
	local degrees = tonumber(degrees_str)&lt;br /&gt;
	local minutes = tonumber(minutes_str) or 0&lt;br /&gt;
	local seconds = tonumber(seconds_str) or 0&lt;br /&gt;
&lt;br /&gt;
	local factor = 1&lt;br /&gt;
	if direction == &amp;quot;S&amp;quot; or direction == &amp;quot;W&amp;quot; then&lt;br /&gt;
		factor = -1&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	local precision = 0&lt;br /&gt;
	if seconds_str then&lt;br /&gt;
		precision = 5 + math.max( math_mod._precision(seconds_str), 0 );&lt;br /&gt;
	elseif minutes_str and minutes_str ~= &#039;&#039; then&lt;br /&gt;
		precision = 3 + math.max( math_mod._precision(minutes_str), 0 );&lt;br /&gt;
	else&lt;br /&gt;
		precision = math.max( math_mod._precision(degrees_str), 0 );&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	local decimal = factor * (degrees+(minutes+seconds/60)/60)&lt;br /&gt;
	return string.format( &amp;quot;%.&amp;quot; .. precision .. &amp;quot;f&amp;quot;, decimal ) -- not tonumber since this whole thing is string based.&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--[[&lt;br /&gt;
Checks input values to for out of range errors.&lt;br /&gt;
]]&lt;br /&gt;
local function validate( lat_d, lat_m, lat_s, long_d, long_m, long_s, source, strong )&lt;br /&gt;
	local errors = {};&lt;br /&gt;
	lat_d = tonumber( lat_d ) or 0;&lt;br /&gt;
	lat_m = tonumber( lat_m ) or 0;&lt;br /&gt;
	lat_s = tonumber( lat_s ) or 0;&lt;br /&gt;
	long_d = tonumber( long_d ) or 0;&lt;br /&gt;
	long_m = tonumber( long_m ) or 0;&lt;br /&gt;
	long_s = tonumber( long_s ) or 0;&lt;br /&gt;
&lt;br /&gt;
	if strong then&lt;br /&gt;
		if lat_d &amp;lt; 0 then&lt;br /&gt;
			table.insert(errors, {source, &amp;quot;latitude degrees &amp;lt; 0 with hemisphere flag&amp;quot;})&lt;br /&gt;
		end&lt;br /&gt;
		if long_d &amp;lt; 0 then&lt;br /&gt;
			table.insert(errors, {source, &amp;quot;longitude degrees &amp;lt; 0 with hemisphere flag&amp;quot;})&lt;br /&gt;
		end&lt;br /&gt;
		--[[&lt;br /&gt;
		#coordinates is inconsistent about whether this is an error.  If globe: is&lt;br /&gt;
		specified, it won&#039;t error on this condition, but otherwise it will.&lt;br /&gt;
&lt;br /&gt;
		For not simply disable this check.&lt;br /&gt;
&lt;br /&gt;
		if long_d &amp;gt; 180 then&lt;br /&gt;
			table.insert(errors, {source, &amp;quot;longitude degrees &amp;gt; 180 with hemisphere flag&amp;quot;})&lt;br /&gt;
		end&lt;br /&gt;
		]]&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	if lat_d &amp;gt; 90 then&lt;br /&gt;
		table.insert(errors, {source, &amp;quot;latitude degrees &amp;gt; 90&amp;quot;})&lt;br /&gt;
	end&lt;br /&gt;
	if lat_d &amp;lt; -90 then&lt;br /&gt;
		table.insert(errors, {source, &amp;quot;latitude degrees &amp;lt; -90&amp;quot;})&lt;br /&gt;
	end&lt;br /&gt;
	if lat_m &amp;gt;= 60 then&lt;br /&gt;
		table.insert(errors, {source, &amp;quot;latitude minutes &amp;gt;= 60&amp;quot;})&lt;br /&gt;
	end&lt;br /&gt;
	if lat_m &amp;lt; 0 then&lt;br /&gt;
		table.insert(errors, {source, &amp;quot;latitude minutes &amp;lt; 0&amp;quot;})&lt;br /&gt;
	end&lt;br /&gt;
	if lat_s &amp;gt;= 60 then&lt;br /&gt;
		table.insert(errors, {source, &amp;quot;latitude seconds &amp;gt;= 60&amp;quot;})&lt;br /&gt;
	end&lt;br /&gt;
	if lat_s &amp;lt; 0 then&lt;br /&gt;
		table.insert(errors, {source, &amp;quot;latitude seconds &amp;lt; 0&amp;quot;})&lt;br /&gt;
	end&lt;br /&gt;
	if long_d &amp;gt;= 360 then&lt;br /&gt;
		table.insert(errors, {source, &amp;quot;longitude degrees &amp;gt;= 360&amp;quot;})&lt;br /&gt;
	end&lt;br /&gt;
	if long_d &amp;lt;= -360 then&lt;br /&gt;
		table.insert(errors, {source, &amp;quot;longitude degrees &amp;lt;= -360&amp;quot;})&lt;br /&gt;
	end&lt;br /&gt;
	if long_m &amp;gt;= 60 then&lt;br /&gt;
		table.insert(errors, {source, &amp;quot;longitude minutes &amp;gt;= 60&amp;quot;})&lt;br /&gt;
	end&lt;br /&gt;
	if long_m &amp;lt; 0 then&lt;br /&gt;
		table.insert(errors, {source, &amp;quot;longitude minutes &amp;lt; 0&amp;quot;})&lt;br /&gt;
	end&lt;br /&gt;
	if long_s &amp;gt;= 60 then&lt;br /&gt;
		table.insert(errors, {source, &amp;quot;longitude seconds &amp;gt;= 60&amp;quot;})&lt;br /&gt;
	end&lt;br /&gt;
	if long_s &amp;lt; 0 then&lt;br /&gt;
		table.insert(errors, {source, &amp;quot;longitude seconds &amp;lt; 0&amp;quot;})&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	return errors;&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--[[&lt;br /&gt;
parseDec&lt;br /&gt;
&lt;br /&gt;
Transforms decimal format latitude and longitude into the&lt;br /&gt;
structure to be used in displaying coordinates&lt;br /&gt;
]]&lt;br /&gt;
local function parseDec( lat, long, format )&lt;br /&gt;
	local coordinateSpec = {}&lt;br /&gt;
	local errors = {}&lt;br /&gt;
&lt;br /&gt;
	if not long then&lt;br /&gt;
		return nil, {{&amp;quot;parseDec&amp;quot;, &amp;quot;Missing longitude&amp;quot;}}&lt;br /&gt;
	elseif not tonumber(long) then&lt;br /&gt;
		return nil, {{&amp;quot;parseDec&amp;quot;, &amp;quot;Longitude could not be parsed as a number: &amp;quot; .. long}}&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	errors = validate( lat, nil, nil, long, nil, nil, &#039;parseDec&#039;, false );&lt;br /&gt;
	coordinateSpec[&amp;quot;dec-lat&amp;quot;]  = lat;&lt;br /&gt;
	coordinateSpec[&amp;quot;dec-long&amp;quot;] = long;&lt;br /&gt;
&lt;br /&gt;
	local mode = coordinates.determineMode( lat, long );&lt;br /&gt;
	coordinateSpec[&amp;quot;dms-lat&amp;quot;]  = convert_dec2dms( lat, &amp;quot;N&amp;quot;, &amp;quot;S&amp;quot;, mode)  -- {{coord/dec2dms|{{{1}}}|N|S|{{coord/prec dec|{{{1}}}|{{{2}}}}}}}&lt;br /&gt;
	coordinateSpec[&amp;quot;dms-long&amp;quot;] = convert_dec2dms( long, &amp;quot;E&amp;quot;, &amp;quot;W&amp;quot;, mode)  -- {{coord/dec2dms|{{{2}}}|E|W|{{coord/prec dec|{{{1}}}|{{{2}}}}}}}&lt;br /&gt;
&lt;br /&gt;
	if format then&lt;br /&gt;
		coordinateSpec.default = format&lt;br /&gt;
	else&lt;br /&gt;
		coordinateSpec.default = &amp;quot;dec&amp;quot;&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	return coordinateSpec, errors&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--[[&lt;br /&gt;
parseDMS&lt;br /&gt;
&lt;br /&gt;
Transforms degrees, minutes, seconds format latitude and longitude&lt;br /&gt;
into the a structure to be used in displaying coordinates&lt;br /&gt;
]]&lt;br /&gt;
local function parseDMS( lat_d, lat_m, lat_s, lat_f, long_d, long_m, long_s, long_f, format )&lt;br /&gt;
	local coordinateSpec, errors, backward = {}, {}&lt;br /&gt;
&lt;br /&gt;
	lat_f = lat_f:upper();&lt;br /&gt;
	long_f = long_f:upper();&lt;br /&gt;
&lt;br /&gt;
	-- Check if specified backward&lt;br /&gt;
	if lat_f == &#039;E&#039; or lat_f == &#039;W&#039; then&lt;br /&gt;
		lat_d, long_d, lat_m, long_m, lat_s, long_s, lat_f, long_f, backward = long_d, lat_d, long_m, lat_m, long_s, lat_s, long_f, lat_f, true;&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	errors = validate( lat_d, lat_m, lat_s, long_d, long_m, long_s, &#039;parseDMS&#039;, true );&lt;br /&gt;
	if not long_d then&lt;br /&gt;
		return nil, {{&amp;quot;parseDMS&amp;quot;, &amp;quot;Missing longitude&amp;quot; }}&lt;br /&gt;
	elseif not tonumber(long_d) then&lt;br /&gt;
		return nil, {{&amp;quot;parseDMS&amp;quot;, &amp;quot;Longitude could not be parsed as a number:&amp;quot; .. long_d }}&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	if not lat_m and not lat_s and not long_m and not long_s and #errors == 0 then&lt;br /&gt;
		if math_mod._precision( lat_d ) &amp;gt; 0 or math_mod._precision( long_d ) &amp;gt; 0 then&lt;br /&gt;
			if lat_f:upper() == &#039;S&#039; then&lt;br /&gt;
				lat_d = &#039;-&#039; .. lat_d;&lt;br /&gt;
			end&lt;br /&gt;
			if long_f:upper() == &#039;W&#039; then&lt;br /&gt;
				long_d = &#039;-&#039; .. long_d;&lt;br /&gt;
			end&lt;br /&gt;
&lt;br /&gt;
			return parseDec( lat_d, long_d, format );&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	coordinateSpec[&amp;quot;dms-lat&amp;quot;]  = lat_d..&amp;quot;°&amp;quot;..optionalArg(lat_m,&amp;quot;′&amp;quot;) .. optionalArg(lat_s,&amp;quot;″&amp;quot;) .. lat_f&lt;br /&gt;
	coordinateSpec[&amp;quot;dms-long&amp;quot;] = long_d..&amp;quot;°&amp;quot;..optionalArg(long_m,&amp;quot;′&amp;quot;) .. optionalArg(long_s,&amp;quot;″&amp;quot;) .. long_f&lt;br /&gt;
	coordinateSpec[&amp;quot;dec-lat&amp;quot;]  = convert_dms2dec(lat_f, lat_d, lat_m, lat_s) -- {{coord/dms2dec|{{{4}}}|{{{1}}}|0{{{2}}}|0{{{3}}}}}&lt;br /&gt;
	coordinateSpec[&amp;quot;dec-long&amp;quot;] = convert_dms2dec(long_f, long_d, long_m, long_s) -- {{coord/dms2dec|{{{8}}}|{{{5}}}|0{{{6}}}|0{{{7}}}}}&lt;br /&gt;
&lt;br /&gt;
	if format then&lt;br /&gt;
		coordinateSpec.default = format&lt;br /&gt;
	else&lt;br /&gt;
		coordinateSpec.default = &amp;quot;dms&amp;quot;&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	return coordinateSpec, errors, backward&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--[[&lt;br /&gt;
Check the input arguments for coord to determine the kind of data being provided&lt;br /&gt;
and then make the necessary processing.&lt;br /&gt;
]]&lt;br /&gt;
local function formatTest(args)&lt;br /&gt;
	local result, errors&lt;br /&gt;
	local backward, primary = false, false&lt;br /&gt;
&lt;br /&gt;
	local function getParam(args, lim)&lt;br /&gt;
		local ret = {}&lt;br /&gt;
		for i = 1, lim do&lt;br /&gt;
			ret[i] = args[i] or &#039;&#039;&lt;br /&gt;
		end&lt;br /&gt;
		return table.concat(ret, &#039;_&#039;)&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	if not args[1] then&lt;br /&gt;
		-- no lat logic&lt;br /&gt;
		return errorPrinter( {{&amp;quot;formatTest&amp;quot;, &amp;quot;Missing latitude&amp;quot;}} )&lt;br /&gt;
	elseif not tonumber(args[1]) then&lt;br /&gt;
		-- bad lat logic&lt;br /&gt;
		return errorPrinter( {{&amp;quot;formatTest&amp;quot;, &amp;quot;Unable to parse latitude as a number:&amp;quot; .. args[1]}} )&lt;br /&gt;
	elseif not args[4] and not args[5] and not args[6] then&lt;br /&gt;
		-- dec logic&lt;br /&gt;
		result, errors = parseDec(args[1], args[2], args.format)&lt;br /&gt;
		if not result then&lt;br /&gt;
			return errorPrinter(errors);&lt;br /&gt;
		end&lt;br /&gt;
		-- formatting for geohack: geohack expects D_N_D_E notation or D;D notation&lt;br /&gt;
		-- wikiminiatlas doesn&#039;t support D;D notation&lt;br /&gt;
		-- #coordinates parserfunction doesn&#039;t support negative decimals with NSWE&lt;br /&gt;
		result.param = table.concat({&lt;br /&gt;
			math.abs(tonumber(args[1])),&lt;br /&gt;
			((tonumber(args[1]) or 0) &amp;lt; 0) and &#039;S&#039; or &#039;N&#039;,&lt;br /&gt;
			math.abs(tonumber(args[2])),&lt;br /&gt;
			((tonumber(args[2]) or 0) &amp;lt; 0) and &#039;W&#039; or &#039;E&#039;,&lt;br /&gt;
			args[3] or &#039;&#039;}, &#039;_&#039;)&lt;br /&gt;
	elseif dmsTest(args[4], args[8]) then&lt;br /&gt;
		-- dms logic&lt;br /&gt;
		result, errors, backward = parseDMS(args[1], args[2], args[3], args[4],&lt;br /&gt;
			args[5], args[6], args[7], args[8], args.format)&lt;br /&gt;
		if args[10] then&lt;br /&gt;
			table.insert(errors, {&#039;formatTest&#039;, &#039;Extra unexpected parameters&#039;})&lt;br /&gt;
		end&lt;br /&gt;
		if not result then&lt;br /&gt;
			return errorPrinter(errors)&lt;br /&gt;
		end&lt;br /&gt;
		result.param = getParam(args, 9)&lt;br /&gt;
	elseif dmsTest(args[3], args[6]) then&lt;br /&gt;
		-- dm logic&lt;br /&gt;
		result, errors, backward = parseDMS(args[1], args[2], nil, args[3],&lt;br /&gt;
			args[4], args[5], nil, args[6], args[&#039;format&#039;])&lt;br /&gt;
		if args[8] then&lt;br /&gt;
			table.insert(errors, {&#039;formatTest&#039;, &#039;Extra unexpected parameters&#039;})&lt;br /&gt;
		end&lt;br /&gt;
		if not result then&lt;br /&gt;
			return errorPrinter(errors)&lt;br /&gt;
		end&lt;br /&gt;
		result.param = getParam(args, 7)&lt;br /&gt;
	elseif dmsTest(args[2], args[4]) then&lt;br /&gt;
		-- d logic&lt;br /&gt;
		result, errors, backward = parseDMS(args[1], nil, nil, args[2],&lt;br /&gt;
			args[3], nil, nil, args[4], args.format)&lt;br /&gt;
		if args[6] then&lt;br /&gt;
			table.insert(errors, {&#039;formatTest&#039;, &#039;Extra unexpected parameters&#039;})&lt;br /&gt;
		end&lt;br /&gt;
		if not result then&lt;br /&gt;
			return errorPrinter(errors)&lt;br /&gt;
		end&lt;br /&gt;
		result.param = getParam(args, 5)&lt;br /&gt;
	else&lt;br /&gt;
		-- Error&lt;br /&gt;
		return errorPrinter({{&amp;quot;formatTest&amp;quot;, &amp;quot;Unknown argument format&amp;quot;}}) .. &#039;[[Category:Pages with malformed coordinate tags]]&#039;&lt;br /&gt;
	end&lt;br /&gt;
	result.name = args.name&lt;br /&gt;
&lt;br /&gt;
	local extra_param = {&#039;dim&#039;, &#039;globe&#039;, &#039;scale&#039;, &#039;region&#039;, &#039;source&#039;, &#039;type&#039;}&lt;br /&gt;
	for _, v in ipairs(extra_param) do&lt;br /&gt;
		if args[v] then&lt;br /&gt;
			table.insert(errors, {&#039;formatTest&#039;, &#039;Parameter: &amp;quot;&#039; .. v .. &#039;=&amp;quot; should be &amp;quot;&#039; .. v .. &#039;:&amp;quot;&#039; })&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	local ret = specPrinter(args, result)&lt;br /&gt;
	if #errors &amp;gt; 0 then&lt;br /&gt;
		ret = ret .. &#039; &#039; .. errorPrinter(errors) .. &#039;[[Category:Pages with malformed coordinate tags]]&#039;&lt;br /&gt;
	end&lt;br /&gt;
	return ret, backward&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--[[&lt;br /&gt;
Generate Wikidata tracking categories.&lt;br /&gt;
]]&lt;br /&gt;
local function makeWikidataCategories(qid)&lt;br /&gt;
	local ret&lt;br /&gt;
	local qid = qid or mw.wikibase.getEntityIdForCurrentPage()&lt;br /&gt;
	if mw.wikibase and current_page.namespace == 0 then&lt;br /&gt;
		if qid and mw.wikibase.entityExists(qid) and mw.wikibase.getBestStatements(qid, &amp;quot;P625&amp;quot;) and mw.wikibase.getBestStatements(qid, &amp;quot;P625&amp;quot;)[1] then&lt;br /&gt;
			local snaktype = mw.wikibase.getBestStatements(qid, &amp;quot;P625&amp;quot;)[1].mainsnak.snaktype&lt;br /&gt;
			if snaktype == &#039;value&#039; then&lt;br /&gt;
				-- coordinates exist both here and on Wikidata, and can be compared.&lt;br /&gt;
				ret = &#039;Coordinates on Wikidata&#039;&lt;br /&gt;
			elseif snaktype == &#039;somevalue&#039; then&lt;br /&gt;
				ret = &#039;Coordinates on Wikidata set to unknown value&#039;&lt;br /&gt;
			elseif snaktype == &#039;novalue&#039; then&lt;br /&gt;
				ret = &#039;Coordinates on Wikidata set to no value&#039;&lt;br /&gt;
			end&lt;br /&gt;
		else&lt;br /&gt;
			-- We have to either import the coordinates to Wikidata or remove them here.&lt;br /&gt;
			ret = &#039;Coordinates not on Wikidata&#039;&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	if ret then&lt;br /&gt;
		return string.format(&#039;[[Category:%s]]&#039;, ret)&lt;br /&gt;
	else&lt;br /&gt;
		return &#039;&#039;&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--[[&lt;br /&gt;
link&lt;br /&gt;
&lt;br /&gt;
Simple function to export the coordinates link for other uses.&lt;br /&gt;
&lt;br /&gt;
Usage:&lt;br /&gt;
	{{#invoke:Coordinates | link }}&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
function coordinates.link(frame)&lt;br /&gt;
	return coord_link;&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--[[&lt;br /&gt;
dec2dms&lt;br /&gt;
&lt;br /&gt;
Wrapper to allow templates to call dec2dms directly.&lt;br /&gt;
&lt;br /&gt;
Usage:&lt;br /&gt;
	{{#invoke:Coordinates | dec2dms | decimal_coordinate | positive_suffix |&lt;br /&gt;
		negative_suffix | precision }}&lt;br /&gt;
&lt;br /&gt;
decimal_coordinate is converted to DMS format.  If positive, the positive_suffix&lt;br /&gt;
is appended (typical N or E), if negative, the negative suffix is appended.  The&lt;br /&gt;
specified precision is one of &#039;D&#039;, &#039;DM&#039;, or &#039;DMS&#039; to specify the level of detail&lt;br /&gt;
to use.&lt;br /&gt;
]]&lt;br /&gt;
coordinates.dec2dms = makeInvokeFunc(&#039;_dec2dms&#039;)&lt;br /&gt;
function coordinates._dec2dms(args)&lt;br /&gt;
	local coordinate = args[1]&lt;br /&gt;
	local firstPostfix = args[2] or &#039;&#039;&lt;br /&gt;
	local secondPostfix = args[3] or &#039;&#039;&lt;br /&gt;
	local precision = args[4] or &#039;&#039;&lt;br /&gt;
&lt;br /&gt;
	return convert_dec2dms(coordinate, firstPostfix, secondPostfix, precision)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--[[&lt;br /&gt;
Helper function to determine whether to use D, DM, or DMS&lt;br /&gt;
format depending on the precision of the decimal input.&lt;br /&gt;
]]&lt;br /&gt;
function coordinates.determineMode( value1, value2 )&lt;br /&gt;
	local precision = math.max( math_mod._precision( value1 ), math_mod._precision( value2 ) );&lt;br /&gt;
	if precision &amp;lt;= 0 then&lt;br /&gt;
		return &#039;d&#039;&lt;br /&gt;
	elseif precision &amp;lt;= 2 then&lt;br /&gt;
		return &#039;dm&#039;;&lt;br /&gt;
	else&lt;br /&gt;
		return &#039;dms&#039;;&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--[[&lt;br /&gt;
dms2dec&lt;br /&gt;
&lt;br /&gt;
Wrapper to allow templates to call dms2dec directly.&lt;br /&gt;
&lt;br /&gt;
Usage:&lt;br /&gt;
	{{#invoke:Coordinates | dms2dec | direction_flag | degrees |&lt;br /&gt;
		minutes | seconds }}&lt;br /&gt;
&lt;br /&gt;
Converts DMS values specified as degrees, minutes, seconds too decimal format.&lt;br /&gt;
direction_flag is one of N, S, E, W, and determines whether the output is&lt;br /&gt;
positive (i.e. N and E) or negative (i.e. S and W).&lt;br /&gt;
]]&lt;br /&gt;
coordinates.dms2dec = makeInvokeFunc(&#039;_dms2dec&#039;)&lt;br /&gt;
function coordinates._dms2dec(args)&lt;br /&gt;
	local direction = args[1]&lt;br /&gt;
	local degrees = args[2]&lt;br /&gt;
	local minutes = args[3]&lt;br /&gt;
	local seconds = args[4]&lt;br /&gt;
&lt;br /&gt;
	return convert_dms2dec(direction, degrees, minutes, seconds)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--[[&lt;br /&gt;
coord&lt;br /&gt;
&lt;br /&gt;
Main entry point for Lua function to replace {{coord}}&lt;br /&gt;
&lt;br /&gt;
Usage:&lt;br /&gt;
	{{#invoke:Coordinates | coord }}&lt;br /&gt;
	{{#invoke:Coordinates | coord | lat | long }}&lt;br /&gt;
	{{#invoke:Coordinates | coord | lat | lat_flag | long | long_flag }}&lt;br /&gt;
	...&lt;br /&gt;
&lt;br /&gt;
	Refer to {{coord}} documentation page for many additional parameters and&lt;br /&gt;
	configuration options.&lt;br /&gt;
&lt;br /&gt;
Note: This function provides the visual display elements of {{coord}}.  In&lt;br /&gt;
order to load coordinates into the database, the {{#coordinates:}} parser&lt;br /&gt;
function must also be called, this is done automatically in the Lua&lt;br /&gt;
version of {{coord}}.&lt;br /&gt;
]]&lt;br /&gt;
coordinates.coord = makeInvokeFunc(&#039;_coord&#039;)&lt;br /&gt;
function coordinates._coord(args)&lt;br /&gt;
	if not tonumber(args[1]) and not args[2] then&lt;br /&gt;
		args[3] = args[1]; args[1] = nil&lt;br /&gt;
		local entity = mw.wikibase.getEntityObject(args.qid)&lt;br /&gt;
		if entity&lt;br /&gt;
			and entity.claims&lt;br /&gt;
			and entity.claims.P625&lt;br /&gt;
			and entity.claims.P625[1].mainsnak.snaktype == &#039;value&#039;&lt;br /&gt;
		then&lt;br /&gt;
			local precision = entity.claims.P625[1].mainsnak.datavalue.value.precision&lt;br /&gt;
			args[1] = entity.claims.P625[1].mainsnak.datavalue.value.latitude&lt;br /&gt;
			args[2] = entity.claims.P625[1].mainsnak.datavalue.value.longitude&lt;br /&gt;
			if precision then&lt;br /&gt;
				precision = -math_mod._round(math.log(precision)/math.log(10),0)&lt;br /&gt;
				args[1] = math_mod._round(args[1],precision)&lt;br /&gt;
				args[2] = math_mod._round(args[2],precision)&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	local contents, backward = formatTest(args)&lt;br /&gt;
	local Notes = args.notes or &#039;&#039;&lt;br /&gt;
	local Display = args.display and args.display:lower() or &#039;inline&#039;&lt;br /&gt;
&lt;br /&gt;
	-- it and ti are short for inline,title and title,inline&lt;br /&gt;
	local function isInline(s)&lt;br /&gt;
		-- Finds whether coordinates are displayed inline.&lt;br /&gt;
		return s:find(&#039;inline&#039;) ~= nil or s == &#039;i&#039; or s == &#039;it&#039; or s == &#039;ti&#039;&lt;br /&gt;
	end&lt;br /&gt;
	local function isInTitle(s)&lt;br /&gt;
		-- Finds whether coordinates are displayed in the title.&lt;br /&gt;
		return s:find(&#039;title&#039;) ~= nil or s == &#039;t&#039; or s == &#039;it&#039; or s == &#039;ti&#039;&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	local function coord_wrapper(in_args)&lt;br /&gt;
		-- Calls the parser function {{#coordinates:}}.&lt;br /&gt;
		return mw.getCurrentFrame():callParserFunction(&#039;#coordinates&#039;, in_args) or &#039;&#039;&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	local text = &#039;&#039;&lt;br /&gt;
	if isInline(Display) then&lt;br /&gt;
		text = text .. &#039;&amp;lt;span class=&amp;quot;geo-inline&amp;quot;&amp;gt;&#039; .. contents .. Notes .. &#039;&amp;lt;/span&amp;gt;&#039;&lt;br /&gt;
	end&lt;br /&gt;
	if isInTitle(Display) then&lt;br /&gt;
		-- Add to output since indicator content is invisible to Lua later on&lt;br /&gt;
		if not isInline(Display) then&lt;br /&gt;
			text = text .. &#039;&amp;lt;span class=&amp;quot;geo-inline-hidden noexcerpt&amp;quot;&amp;gt;&#039; .. contents .. Notes .. &#039;&amp;lt;/span&amp;gt;&#039;&lt;br /&gt;
		end&lt;br /&gt;
		text = text .. displaytitle(contents .. Notes) .. makeWikidataCategories(args.qid)&lt;br /&gt;
	end&lt;br /&gt;
	if not args.nosave then&lt;br /&gt;
		local page_title, count = mw.title.getCurrentTitle(), 1&lt;br /&gt;
		if backward then&lt;br /&gt;
			local tmp = {}&lt;br /&gt;
			while not string.find((args[count-1] or &#039;&#039;), &#039;[EW]&#039;) do tmp[count] = (args[count] or &#039;&#039;); count = count+1 end&lt;br /&gt;
			tmp.count = count; count = 2*(count-1)&lt;br /&gt;
			while count &amp;gt;= tmp.count do table.insert(tmp, 1, (args[count] or &#039;&#039;)); count = count-1 end&lt;br /&gt;
			for i, v in ipairs(tmp) do args[i] = v end&lt;br /&gt;
		else&lt;br /&gt;
			while count &amp;lt;= 9 do args[count] = (args[count] or &#039;&#039;); count = count+1 end&lt;br /&gt;
		end&lt;br /&gt;
		if isInTitle(Display) and not page_title.isTalkPage and page_title.subpageText ~= &#039;doc&#039; and page_title.subpageText ~= &#039;testcases&#039; then args[10] = &#039;primary&#039; end&lt;br /&gt;
		args.notes, args.format, args.display = nil&lt;br /&gt;
		text = text .. coord_wrapper(args)&lt;br /&gt;
	end&lt;br /&gt;
	return text&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--[[&lt;br /&gt;
coord2text&lt;br /&gt;
&lt;br /&gt;
Extracts a single value from a transclusion of {{Coord}}.&lt;br /&gt;
IF THE GEOHACK LINK SYNTAX CHANGES THIS FUNCTION MUST BE MODIFIED.&lt;br /&gt;
&lt;br /&gt;
Usage:&lt;br /&gt;
&lt;br /&gt;
    {{#invoke:Coordinates | coord2text | {{Coord}} | parameter }}&lt;br /&gt;
&lt;br /&gt;
Valid values for the second parameter are: lat (signed integer), long (signed integer), type, scale, dim, region, globe, source&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
function coordinates._coord2text(coord,type)&lt;br /&gt;
	if coord == &#039;&#039; or type == &#039;&#039; or not type then return nil end&lt;br /&gt;
	type = mw.text.trim(type)&lt;br /&gt;
	if type == &#039;lat&#039; or type == &#039;long&#039; then&lt;br /&gt;
		local result, negative = mw.text.split((mw.ustring.match(coord,&#039;[%.%d]+°[NS] [%.%d]+°[EW]&#039;) or &#039;&#039;), &#039; &#039;)&lt;br /&gt;
		if type == &#039;lat&#039; then&lt;br /&gt;
			result, negative = result[1], &#039;S&#039;&lt;br /&gt;
		else&lt;br /&gt;
			result, negative = result[2], &#039;W&#039;&lt;br /&gt;
		end&lt;br /&gt;
		result = mw.text.split(result, &#039;°&#039;)&lt;br /&gt;
		if result[2] == negative then result[1] = &#039;-&#039;..result[1] end&lt;br /&gt;
		return result[1]&lt;br /&gt;
	else&lt;br /&gt;
		return mw.ustring.match(coord, &#039;params=.-_&#039; .. type .. &#039;:(.-)[ _]&#039;)&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function coordinates.coord2text(frame)&lt;br /&gt;
	return coordinates._coord2text(frame.args[1],frame.args[2])&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--[[&lt;br /&gt;
coordinsert&lt;br /&gt;
&lt;br /&gt;
Injects some text into the Geohack link of a transclusion of {{Coord}} (if that text isn&#039;t already in the transclusion). Outputs the modified transclusion of {{Coord}}.&lt;br /&gt;
IF THE GEOHACK LINK SYNTAX CHANGES THIS FUNCTION MUST BE MODIFIED.&lt;br /&gt;
&lt;br /&gt;
Usage:&lt;br /&gt;
&lt;br /&gt;
    {{#invoke:Coordinates | coordinsert | {{Coord}} | parameter:value | parameter:value | … }}&lt;br /&gt;
&lt;br /&gt;
Do not make Geohack unhappy by inserting something which isn&#039;t mentioned in the {{Coord}} documentation.&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
function coordinates.coordinsert(frame)&lt;br /&gt;
	-- for the 2nd or later integer parameter (the first is the coord template, as above)&lt;br /&gt;
	for i, v in ipairs(frame.args) do&lt;br /&gt;
		if i ~= 1 then&lt;br /&gt;
			-- if we cannot find in the coord_template the i_th coordinsert parameter e.g. region&lt;br /&gt;
			if not mw.ustring.find(frame.args[1], (mw.ustring.match(frame.args[i], &#039;^(.-:)&#039;) or &#039;&#039;)) then&lt;br /&gt;
				-- find from the params= up to the first possibly-present underscore&lt;br /&gt;
				-- and append the i_th coordinsert parameter and a space&lt;br /&gt;
				-- IDK why we&#039;re adding a space but it does seem somewhat convenient&lt;br /&gt;
				frame.args[1] = mw.ustring.gsub(frame.args[1], &#039;(params=.-)_? &#039;, &#039;%1_&#039;..frame.args[i]..&#039; &#039;)&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	if frame.args.name then&lt;br /&gt;
		-- if we can&#039;t find the vcard class&lt;br /&gt;
		if not mw.ustring.find(frame.args[1], &#039;&amp;lt;span class=&amp;quot;vcard&amp;quot;&amp;gt;&#039;) then&lt;br /&gt;
			-- take something that looks like a coord template and add the vcard span with class and fn org class&lt;br /&gt;
			local namestr = frame.args.name&lt;br /&gt;
			frame.args[1] = mw.ustring.gsub(&lt;br /&gt;
				frame.args[1],&lt;br /&gt;
				&#039;(&amp;lt;span class=&amp;quot;geo%-default&amp;quot;&amp;gt;)(&amp;lt;span[^&amp;lt;&amp;gt;]*&amp;gt;[^&amp;lt;&amp;gt;]*&amp;lt;/span&amp;gt;&amp;lt;span[^&amp;lt;&amp;gt;]*&amp;gt;[^&amp;lt;&amp;gt;]*&amp;lt;span[^&amp;lt;&amp;gt;]*&amp;gt;[^&amp;lt;&amp;gt;]*&amp;lt;/span&amp;gt;&amp;lt;/span&amp;gt;)(&amp;lt;/span&amp;gt;)&#039;,&lt;br /&gt;
				&#039;%1&amp;lt;span class=&amp;quot;vcard&amp;quot;&amp;gt;%2&amp;lt;span style=&amp;quot;display:none&amp;quot;&amp;gt;&amp;amp;#xfeff; (&amp;lt;span class=&amp;quot;fn org&amp;quot;&amp;gt;&#039; .. namestr .. &#039;&amp;lt;/span&amp;gt;)&amp;lt;/span&amp;gt;&amp;lt;/span&amp;gt;%3&#039;&lt;br /&gt;
			)&lt;br /&gt;
			-- then find anything from coordinates parameters to the &#039;end&#039; and attach the title parameter&lt;br /&gt;
			frame.args[1] = mw.ustring.gsub(&lt;br /&gt;
				frame.args[1],&lt;br /&gt;
				&#039;(&amp;amp;params=[^&amp;amp;&amp;quot;&amp;lt;&amp;gt;%[%] ]*) &#039;,&lt;br /&gt;
				&#039;%1&amp;amp;title=&#039; .. mw.uri.encode(namestr) .. &#039; &#039;&lt;br /&gt;
			)&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	-- replace the existing indicator with a new indicator using the modified content&lt;br /&gt;
	frame.args[1] = mw.ustring.gsub(&lt;br /&gt;
		frame.args[1],&lt;br /&gt;
		&#039;(&amp;lt;span class=&amp;quot;geo%-inline[^&amp;quot;]*&amp;quot;&amp;gt;(.+)&amp;lt;/span&amp;gt;)\127[^\127]*UNIQ%-%-indicator%-%x+%-%-?QINU[^\127]*\127&#039;,&lt;br /&gt;
		function (inline, coord) return inline .. displaytitle(coord) end&lt;br /&gt;
	)&lt;br /&gt;
&lt;br /&gt;
	return frame.args[1]&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
return coordinates&lt;/div&gt;</summary>
		<author><name>Marie</name></author>
	</entry>
	<entry>
		<id>http://project-au.w.kmwc.org/index.php?title=Module:Citation/CS1/Identifiers&amp;diff=2093</id>
		<title>Module:Citation/CS1/Identifiers</title>
		<link rel="alternate" type="text/html" href="http://project-au.w.kmwc.org/index.php?title=Module:Citation/CS1/Identifiers&amp;diff=2093"/>
		<updated>2026-01-16T10:08:54Z</updated>

		<summary type="html">&lt;p&gt;Marie: 1 revision imported&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;--[[--------------------------&amp;lt; F O R W A R D   D E C L A R A T I O N S &amp;gt;--------------------------------------&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local has_accept_as_written, is_set, in_array, set_message, select_one,			-- functions in Module:Citation/CS1/Utilities&lt;br /&gt;
		substitute, make_wikilink;&lt;br /&gt;
&lt;br /&gt;
local z;																		-- table of tables defined in Module:Citation/CS1/Utilities&lt;br /&gt;
&lt;br /&gt;
local cfg;																		-- table of configuration tables that are defined in Module:Citation/CS1/Configuration&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[--------------------------&amp;lt; P A G E   S C O P E   V A R I A B L E S &amp;gt;--------------------------------------&lt;br /&gt;
&lt;br /&gt;
declare variables here that have page-wide scope that are not brought in from other modules; that are created here and used here&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local auto_link_urls = {};														-- holds identifier URLs for those identifiers that can auto-link |title=&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--============================&amp;lt;&amp;lt; H E L P E R   F U N C T I O N S &amp;gt;&amp;gt;============================================&lt;br /&gt;
&lt;br /&gt;
--[[--------------------------&amp;lt; W I K I D A T A _ A R T I C L E _ N A M E _ G E T &amp;gt;----------------------------&lt;br /&gt;
&lt;br /&gt;
as an aid to internationalizing identifier-label wikilinks, gets identifier article names from Wikidata.&lt;br /&gt;
&lt;br /&gt;
returns :&amp;lt;lang code&amp;gt;:&amp;lt;article title&amp;gt; when &amp;lt;q&amp;gt; has an &amp;lt;article title&amp;gt; for &amp;lt;lang code&amp;gt;; nil else&lt;br /&gt;
&lt;br /&gt;
for identifiers that do not have q, returns nil&lt;br /&gt;
&lt;br /&gt;
for wikis that do not have mw.wikibase installed, returns nil&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function wikidata_article_name_get (q)&lt;br /&gt;
	if not is_set (q) or (q and not mw.wikibase) then							-- when no q number or when a q number but mw.wikibase not installed on this wiki&lt;br /&gt;
		return nil;																-- abandon&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	local wd_article;&lt;br /&gt;
	local this_wiki_code = cfg.this_wiki_code;									-- Wikipedia subdomain; &#039;en&#039; for en.wikipedia.org&lt;br /&gt;
&lt;br /&gt;
	wd_article = mw.wikibase.getSitelink (q, this_wiki_code .. &#039;wiki&#039;);			-- fetch article title from WD; nil when no title available at this wiki&lt;br /&gt;
&lt;br /&gt;
	if wd_article then&lt;br /&gt;
		wd_article = table.concat ({&#039;:&#039;, this_wiki_code, &#039;:&#039;, wd_article});		-- interwiki-style link without brackets if taken from WD; leading colon required&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	return wd_article;															-- article title from WD; nil else&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[--------------------------&amp;lt; L I N K _ L A B E L _ M A K E &amp;gt;------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
common function to create identifier link label from handler table or from Wikidata&lt;br /&gt;
&lt;br /&gt;
returns the first available of&lt;br /&gt;
	1. redirect from local wiki&#039;s handler table (if enabled)&lt;br /&gt;
	2. Wikidata (if there is a Wikidata entry for this identifier in the local wiki&#039;s language)&lt;br /&gt;
	3. label specified in the local wiki&#039;s handler table&lt;br /&gt;
	&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function link_label_make (handler)&lt;br /&gt;
	local wd_article;&lt;br /&gt;
	&lt;br /&gt;
	if not (cfg.use_identifier_redirects and is_set (handler.redirect)) then	-- redirect has priority so if enabled and available don&#039;t fetch from Wikidata because expensive&lt;br /&gt;
		wd_article = wikidata_article_name_get (handler.q);						-- if Wikidata has an article title for this wiki, get it;&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	return (cfg.use_identifier_redirects and is_set (handler.redirect) and handler.redirect) or wd_article or handler.link;&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[--------------------------&amp;lt; E X T E R N A L _ L I N K _ I D &amp;gt;----------------------------------------------&lt;br /&gt;
&lt;br /&gt;
Formats a wiki-style external link&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function external_link_id (options)&lt;br /&gt;
	local url_string = options.id;&lt;br /&gt;
	local ext_link;&lt;br /&gt;
	local this_wiki_code = cfg.this_wiki_code;									-- Wikipedia subdomain; &#039;en&#039; for en.wikipedia.org&lt;br /&gt;
	local wd_article;															-- article title from Wikidata&lt;br /&gt;
	&lt;br /&gt;
	if options.encode == true or options.encode == nil then&lt;br /&gt;
		url_string = mw.uri.encode (url_string, &#039;PATH&#039;);&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	if options.auto_link and is_set (options.access) then&lt;br /&gt;
		auto_link_urls[options.auto_link] = table.concat ({options.prefix, url_string, options.suffix});&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	ext_link = mw.ustring.format (&#039;[%s%s%s %s]&#039;, options.prefix, url_string, options.suffix or &amp;quot;&amp;quot;, mw.text.nowiki (options.id));&lt;br /&gt;
	if is_set (options.access) then&lt;br /&gt;
		ext_link = substitute (cfg.presentation[&#039;ext-link-access-signal&#039;], {cfg.presentation[options.access].class, cfg.presentation[options.access].title, ext_link});	-- add the free-to-read / paywall lock&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	return table.concat	({&lt;br /&gt;
		make_wikilink (link_label_make (options), options.label),				-- redirect, Wikidata link, or locally specified link (in that order)&lt;br /&gt;
		options.separator or &#039;&amp;amp;nbsp;&#039;,&lt;br /&gt;
		ext_link&lt;br /&gt;
		});&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[--------------------------&amp;lt; I N T E R N A L _ L I N K _ I D &amp;gt;----------------------------------------------&lt;br /&gt;
&lt;br /&gt;
Formats a wiki-style internal link&lt;br /&gt;
&lt;br /&gt;
TODO: Does not currently need to support options.access, options.encode, auto-linking and COinS (as in external_link_id),&lt;br /&gt;
but may be needed in the future for :m:Interwiki_map custom-prefixes like :arxiv:, :bibcode:, :DOI:, :hdl:, :ISSN:,&lt;br /&gt;
:JSTOR:, :Openlibrary:, :PMID:, :RFC:.&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function internal_link_id (options)&lt;br /&gt;
	local id = mw.ustring.gsub (options.id, &#039;%d&#039;, cfg.date_names.local_digits);	-- translate &#039;local&#039; digits to Western 0-9&lt;br /&gt;
&lt;br /&gt;
	return table.concat (&lt;br /&gt;
		{&lt;br /&gt;
		make_wikilink (link_label_make (options), options.label),				-- wiki-link the identifier label&lt;br /&gt;
		options.separator or &#039;&amp;amp;nbsp;&#039;,											-- add the separator&lt;br /&gt;
		make_wikilink (&lt;br /&gt;
			table.concat (&lt;br /&gt;
				{&lt;br /&gt;
				options.prefix,&lt;br /&gt;
				id,																-- translated to Western digits&lt;br /&gt;
				options.suffix or &#039;&#039;&lt;br /&gt;
				}),&lt;br /&gt;
			substitute (cfg.presentation[&#039;bdi&#039;], {&#039;&#039;, mw.text.nowiki (options.id)})	-- bdi tags to prevent Latin script identifiers from being reversed at RTL language wikis&lt;br /&gt;
			);																	-- nowiki because MediaWiki still has magic links for ISBN and the like; TODO: is it really required?&lt;br /&gt;
		});&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[--------------------------&amp;lt; I S _ E M B A R G O E D &amp;gt;------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
Determines if a PMC identifier&#039;s online version is embargoed. Compares the date in |pmc-embargo-date= against&lt;br /&gt;
today&#039;s date.  If embargo date is in the future, returns the content of |pmc-embargo-date=; otherwise, returns&lt;br /&gt;
an empty string because the embargo has expired or because |pmc-embargo-date= was not set in this cite.&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function is_embargoed (embargo)&lt;br /&gt;
	if is_set (embargo) then&lt;br /&gt;
		local lang = mw.getContentLanguage();&lt;br /&gt;
		local good1, embargo_date, todays_date;&lt;br /&gt;
		good1, embargo_date = pcall (lang.formatDate, lang, &#039;U&#039;, embargo);&lt;br /&gt;
		todays_date = lang:formatDate (&#039;U&#039;);&lt;br /&gt;
	&lt;br /&gt;
		if good1 then															-- if embargo date is a good date&lt;br /&gt;
			if tonumber (embargo_date) &amp;gt;= tonumber (todays_date) then			-- is embargo date is in the future?&lt;br /&gt;
				return embargo;													-- still embargoed&lt;br /&gt;
			else&lt;br /&gt;
				set_message (&#039;maint_pmc_embargo&#039;);								-- embargo has expired; add main cat&lt;br /&gt;
				return &#039;&#039;;														-- unset because embargo has expired&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	return &#039;&#039;;																	-- |pmc-embargo-date= not set return empty string&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[=[-------------------------&amp;lt; I S _ V A L I D _ R X I V _ D A T E &amp;gt;------------------------------------------&lt;br /&gt;
&lt;br /&gt;
for biorxiv, returns true if:&lt;br /&gt;
	2019-12-11T00:00Z &amp;lt;= biorxiv_date &amp;lt; today + 2 days&lt;br /&gt;
for medrxiv, returns true if:&lt;br /&gt;
	2020-01-01T00:00Z &amp;lt;= medrxiv_date &amp;lt; today + 2 days&lt;br /&gt;
	&lt;br /&gt;
The dated form of biorxiv identifier has a start date of 2019-12-11.  The Unix timestamp for that date is {{#time:U|2019-12-11}} = 1576022400&lt;br /&gt;
The medrxiv identifier has a start date of 2020-01-01.  The Unix timestamp for that date is {{#time:U|2020-01-01}} = 1577836800&lt;br /&gt;
&lt;br /&gt;
&amp;lt;rxiv_date&amp;gt; is the date provided in those |biorxiv= parameter values that are dated and in |medrxiv= parameter values at time 00:00:00 UTC&lt;br /&gt;
&amp;lt;today&amp;gt; is the current date at time 00:00:00 UTC plus 48 hours&lt;br /&gt;
	if today&#039;s date is 2023-01-01T00:00:00 then&lt;br /&gt;
		adding 24 hours gives 2023-01-02T00:00:00 – one second more than today&lt;br /&gt;
		adding 24 hours gives 2023-01-03T00:00:00 – one second more than tomorrow&lt;br /&gt;
&lt;br /&gt;
inputs:&lt;br /&gt;
	&amp;lt;y&amp;gt;, &amp;lt;m&amp;gt;, &amp;lt;d&amp;gt; – year, month, day parts of the date from the birxiv or medrxiv identifier&lt;br /&gt;
	&amp;lt;select&amp;gt; &#039;b&#039; for biorxiv, &#039;m&#039; for medrxiv; defaults to &#039;b&#039;&lt;br /&gt;
&lt;br /&gt;
]=]&lt;br /&gt;
&lt;br /&gt;
local function is_valid_rxiv_date (y, m, d, select)&lt;br /&gt;
	if 0 == tonumber (m) and 12 &amp;lt; tonumber (m) then								-- &amp;lt;m&amp;gt; must be a number 1–12&lt;br /&gt;
		return false;&lt;br /&gt;
	end&lt;br /&gt;
	if 0 == tonumber (d) and 31 &amp;lt; tonumber (d) then								-- &amp;lt;d&amp;gt; must be a number 1–31; TODO: account for month length and leap yer?&lt;br /&gt;
		return false;&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	local rxiv_date = table.concat ({y, m, d}, &#039;-&#039;);							-- make ymd date string&lt;br /&gt;
	local good1, good2;&lt;br /&gt;
	local rxiv_ts, tomorrow_ts;													-- to hold Unix timestamps representing the dates&lt;br /&gt;
	local lang_object = mw.getContentLanguage();&lt;br /&gt;
&lt;br /&gt;
	good1, rxiv_ts = pcall (lang_object.formatDate, lang_object, &#039;U&#039;, rxiv_date);		-- convert rxiv_date value to Unix timestamp &lt;br /&gt;
	good2, tomorrow_ts = pcall (lang_object.formatDate, lang_object, &#039;U&#039;, &#039;today + 2 days&#039; );	-- today midnight + 2 days is one second more than all day tomorrow&lt;br /&gt;
	&lt;br /&gt;
	if good1 and good2 then														-- lang.formatDate() returns a timestamp in the local script which tonumber() may not understand&lt;br /&gt;
		rxiv_ts = tonumber (rxiv_ts) or lang_object:parseFormattedNumber (rxiv_ts);	-- convert to numbers for the comparison;&lt;br /&gt;
		tomorrow_ts = tonumber (tomorrow_ts) or lang_object:parseFormattedNumber (tomorrow_ts);&lt;br /&gt;
	else&lt;br /&gt;
		return false;															-- one or both failed to convert to Unix timestamp&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	local limit_ts = ((select and (&#039;m&#039; == select)) and 1577836800) or 1576022400;	-- choose the appropriate limit timesatmp&lt;br /&gt;
&lt;br /&gt;
	return ((limit_ts &amp;lt;= rxiv_ts) and (rxiv_ts &amp;lt; tomorrow_ts))					-- limit_ts &amp;lt;= rxiv_date &amp;lt; tomorrow&#039;s date&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[--------------------------&amp;lt; IS _ V A L I D _ I S X N &amp;gt;-----------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
ISBN-10 and ISSN validator code calculates checksum across all ISBN/ISSN digits including the check digit.&lt;br /&gt;
ISBN-13 is checked in isbn().&lt;br /&gt;
&lt;br /&gt;
If the number is valid the result will be 0. Before calling this function, ISBN/ISSN must be checked for length&lt;br /&gt;
and stripped of dashes, spaces and other non-ISxN characters.&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function is_valid_isxn (isxn_str, len)&lt;br /&gt;
	local temp = 0;&lt;br /&gt;
	isxn_str = { isxn_str:byte(1, len) };										-- make a table of byte values &#039;0&#039; → 0x30 .. &#039;9&#039; → 0x39, &#039;X&#039; → 0x58&lt;br /&gt;
	len = len + 1;																-- adjust to be a loop counter&lt;br /&gt;
	for i, v in ipairs (isxn_str) do											-- loop through all of the bytes and calculate the checksum&lt;br /&gt;
		if v == string.byte (&amp;quot;X&amp;quot; ) then											-- if checkdigit is X (compares the byte value of &#039;X&#039; which is 0x58)&lt;br /&gt;
			temp = temp + 10 * (len - i);										-- it represents 10 decimal&lt;br /&gt;
		else&lt;br /&gt;
			temp = temp + tonumber (string.char (v) )*(len-i);&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	return temp % 11 == 0;														-- returns true if calculation result is zero&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[--------------------------&amp;lt; IS _ V A L I D _ I S X N _ 1 3 &amp;gt;-----------------------------------------------&lt;br /&gt;
&lt;br /&gt;
ISBN-13 and ISMN validator code calculates checksum across all 13 ISBN/ISMN digits including the check digit.&lt;br /&gt;
If the number is valid, the result will be 0. Before calling this function, ISBN-13/ISMN must be checked for length&lt;br /&gt;
and stripped of dashes, spaces and other non-ISxN-13 characters.&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function is_valid_isxn_13 (isxn_str)&lt;br /&gt;
	local temp=0;&lt;br /&gt;
	&lt;br /&gt;
	isxn_str = { isxn_str:byte(1, 13) };										-- make a table of byte values &#039;0&#039; → 0x30 .. &#039;9&#039; → 0x39&lt;br /&gt;
	for i, v in ipairs (isxn_str) do&lt;br /&gt;
		temp = temp + (3 - 2*(i % 2)) * tonumber (string.char (v) );			-- multiply odd index digits by 1, even index digits by 3 and sum; includes check digit&lt;br /&gt;
	end&lt;br /&gt;
	return temp % 10 == 0;														-- sum modulo 10 is zero when ISBN-13/ISMN is correct&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[--------------------------&amp;lt; N O R M A L I Z E _ L C C N &amp;gt;--------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
LCCN normalization (https://www.loc.gov/marc/lccn-namespace.html#normalization)&lt;br /&gt;
1. Remove all blanks.&lt;br /&gt;
2. If there is a forward slash (/) in the string, remove it, and remove all characters to the right of the forward slash.&lt;br /&gt;
3. If there is a hyphen in the string:&lt;br /&gt;
	a. Remove it.&lt;br /&gt;
	b. Inspect the substring following (to the right of) the (removed) hyphen. Then (and assuming that steps 1 and 2 have been carried out):&lt;br /&gt;
		1. All these characters should be digits, and there should be six or less. (not done in this function)&lt;br /&gt;
		2. If the length of the substring is less than 6, left-fill the substring with zeroes until the length is six.&lt;br /&gt;
&lt;br /&gt;
Returns a normalized LCCN for lccn() to validate.  There is no error checking (step 3.b.1) performed in this function.&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function normalize_lccn (lccn)&lt;br /&gt;
	lccn = lccn:gsub (&amp;quot;%s&amp;quot;, &amp;quot;&amp;quot;);												-- 1. strip whitespace&lt;br /&gt;
&lt;br /&gt;
	if nil ~= string.find (lccn, &#039;/&#039;) then&lt;br /&gt;
		lccn = lccn:match (&amp;quot;(.-)/&amp;quot;);											-- 2. remove forward slash and all character to the right of it&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	local prefix&lt;br /&gt;
	local suffix&lt;br /&gt;
	prefix, suffix = lccn:match (&amp;quot;(.+)%-(.+)&amp;quot;);									-- 3.a remove hyphen by splitting the string into prefix and suffix&lt;br /&gt;
&lt;br /&gt;
	if nil ~= suffix then														-- if there was a hyphen&lt;br /&gt;
		suffix = string.rep(&amp;quot;0&amp;quot;, 6-string.len (suffix)) .. suffix;				-- 3.b.2 left fill the suffix with 0s if suffix length less than 6&lt;br /&gt;
		lccn = prefix..suffix;													-- reassemble the LCCN&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	return lccn;&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--============================&amp;lt;&amp;lt; I D E N T I F I E R   F U N C T I O N S &amp;gt;&amp;gt;====================================&lt;br /&gt;
&lt;br /&gt;
--[[--------------------------&amp;lt; A R X I V &amp;gt;--------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
See: https://arxiv.org/help/arxiv_identifier&lt;br /&gt;
&lt;br /&gt;
format and error check arXiv identifier.  There are three valid forms of the identifier:&lt;br /&gt;
the first form, valid only between date codes 9107 and 0703, is:&lt;br /&gt;
	arXiv:&amp;lt;archive&amp;gt;.&amp;lt;class&amp;gt;/&amp;lt;date code&amp;gt;&amp;lt;number&amp;gt;&amp;lt;version&amp;gt;&lt;br /&gt;
where:&lt;br /&gt;
	&amp;lt;archive&amp;gt; is a string of alpha characters - may be hyphenated; no other punctuation&lt;br /&gt;
	&amp;lt;class&amp;gt; is a string of alpha characters - may be hyphenated; no other punctuation; not the same as |class= parameter which is not supported in this form&lt;br /&gt;
	&amp;lt;date code&amp;gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01&lt;br /&gt;
		first digit of YY for this form can only 9 and 0&lt;br /&gt;
	&amp;lt;number&amp;gt; is a three-digit number&lt;br /&gt;
	&amp;lt;version&amp;gt; is a 1 or more digit number preceded with a lowercase v; no spaces (undocumented)&lt;br /&gt;
	&lt;br /&gt;
the second form, valid from April 2007 through December 2014 is:&lt;br /&gt;
	arXiv:&amp;lt;date code&amp;gt;.&amp;lt;number&amp;gt;&amp;lt;version&amp;gt;&lt;br /&gt;
where:&lt;br /&gt;
	&amp;lt;date code&amp;gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01&lt;br /&gt;
	&amp;lt;number&amp;gt; is a four-digit number&lt;br /&gt;
	&amp;lt;version&amp;gt; is a 1 or more digit number preceded with a lowercase v; no spaces&lt;br /&gt;
&lt;br /&gt;
the third form, valid from January 2015 is:&lt;br /&gt;
	arXiv:&amp;lt;date code&amp;gt;.&amp;lt;number&amp;gt;&amp;lt;version&amp;gt;&lt;br /&gt;
where:&lt;br /&gt;
	&amp;lt;date code&amp;gt; and &amp;lt;version&amp;gt; are as defined for 0704-1412&lt;br /&gt;
	&amp;lt;number&amp;gt; is a five-digit number&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function arxiv (options)&lt;br /&gt;
	local id = options.id;&lt;br /&gt;
	local class = options.Class;												-- TODO: lowercase?&lt;br /&gt;
	local handler = options.handler;&lt;br /&gt;
	local year, month, version;&lt;br /&gt;
	local err_msg = false;														-- assume no error message&lt;br /&gt;
	local text;																	-- output text&lt;br /&gt;
	&lt;br /&gt;
	if id:match(&amp;quot;^%a[%a%.%-]+/[90]%d[01]%d%d%d%d$&amp;quot;) or id:match(&amp;quot;^%a[%a%.%-]+/[90]%d[01]%d%d%d%dv%d+$&amp;quot;) then	-- test for the 9107-0703 format with or without version&lt;br /&gt;
		year, month = id:match(&amp;quot;^%a[%a%.%-]+/([90]%d)([01]%d)%d%d%d[v%d]*$&amp;quot;);&lt;br /&gt;
		year = tonumber (year);&lt;br /&gt;
		month = tonumber (month);&lt;br /&gt;
		if ((not (90 &amp;lt; year or 8 &amp;gt; year)) or (1 &amp;gt; month or 12 &amp;lt; month)) or		-- if invalid year or invalid month&lt;br /&gt;
			((91 == year and 7 &amp;gt; month) or (7 == year and 3 &amp;lt; month)) then		-- if years ok, are starting and ending months ok?&lt;br /&gt;
				err_msg = true;													-- flag for error message&lt;br /&gt;
		end&lt;br /&gt;
&lt;br /&gt;
	elseif id:match(&amp;quot;^%d%d[01]%d%.%d%d%d%d$&amp;quot;) or id:match(&amp;quot;^%d%d[01]%d%.%d%d%d%dv%d+$&amp;quot;) then	-- test for the 0704-1412 with or without version&lt;br /&gt;
		year, month = id:match(&amp;quot;^(%d%d)([01]%d)%.%d%d%d%d[v%d]*$&amp;quot;);&lt;br /&gt;
		year = tonumber (year);&lt;br /&gt;
		month = tonumber (month);&lt;br /&gt;
		if ((7 &amp;gt; year) or (14 &amp;lt; year) or (1 &amp;gt; month or 12 &amp;lt; month)) or			-- is year invalid or is month invalid? (doesn&#039;t test for future years)&lt;br /&gt;
			((7 == year) and (4 &amp;gt; month)) then									-- when year is 07, is month invalid (before April)?&lt;br /&gt;
				err_msg = true;													-- flag for error message&lt;br /&gt;
		end&lt;br /&gt;
&lt;br /&gt;
	elseif id:match(&amp;quot;^%d%d[01]%d%.%d%d%d%d%d$&amp;quot;) or id:match(&amp;quot;^%d%d[01]%d%.%d%d%d%d%dv%d+$&amp;quot;) then	-- test for the 1501- format with or without version&lt;br /&gt;
		year, month = id:match(&amp;quot;^(%d%d)([01]%d)%.%d%d%d%d%d[v%d]*$&amp;quot;);&lt;br /&gt;
		year = tonumber (year);&lt;br /&gt;
		month = tonumber (month);&lt;br /&gt;
		if ((15 &amp;gt; year) or (1 &amp;gt; month or 12 &amp;lt; month)) then						-- is year invalid or is month invalid? (doesn&#039;t test for future years)&lt;br /&gt;
			err_msg = true;														-- flag for error message&lt;br /&gt;
		end&lt;br /&gt;
&lt;br /&gt;
	else&lt;br /&gt;
		err_msg = true;															-- not a recognized format; flag for error message&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	if err_msg then&lt;br /&gt;
		options.coins_list_t[&#039;ARXIV&#039;] = nil;									-- when error, unset so not included in COinS&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	local err_msg_t = {};&lt;br /&gt;
	if err_msg then&lt;br /&gt;
		set_message (&#039;err_bad_arxiv&#039;);&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	text = external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,&lt;br /&gt;
			prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode, access = handler.access});&lt;br /&gt;
&lt;br /&gt;
	if is_set (class) then&lt;br /&gt;
		if id:match (&#039;^%d+&#039;) then&lt;br /&gt;
			text = table.concat ({text, &#039; [[https://arxiv.org/archive/&#039;, class, &#039; &#039;, class, &#039;]]&#039;});	-- external link within square brackets, not wikilink&lt;br /&gt;
		else&lt;br /&gt;
			set_message (&#039;err_class_ignored&#039;);&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	return text;&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[--------------------------&amp;lt; B I B C O D E &amp;gt;--------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
Validates (sort of) and formats a bibcode ID.&lt;br /&gt;
&lt;br /&gt;
Format for bibcodes is specified here: https://adsabs.harvard.edu/abs_doc/help_pages/data.html#bibcodes&lt;br /&gt;
&lt;br /&gt;
But, this: 2015arXiv151206696F is apparently valid so apparently, the only things that really matter are length, 19 characters&lt;br /&gt;
and first four digits must be a year.  This function makes these tests:&lt;br /&gt;
	length must be 19 characters&lt;br /&gt;
	characters in position&lt;br /&gt;
		1–4 must be digits and must represent a year in the range of 1000 – next year&lt;br /&gt;
		5 must be a letter&lt;br /&gt;
		6–8 must be letter, digit, ampersand, or dot (ampersand cannot directly precede a dot; &amp;amp;. )&lt;br /&gt;
		9–18 must be letter, digit, or dot&lt;br /&gt;
		19 must be a letter or dot&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function bibcode (options)&lt;br /&gt;
	local id = options.id;&lt;br /&gt;
	local access = options.access;&lt;br /&gt;
	local handler = options.handler;&lt;br /&gt;
	local ignore_invalid = options.accept;&lt;br /&gt;
	local err_type;&lt;br /&gt;
	local err_msg = &#039;&#039;;&lt;br /&gt;
	local year;&lt;br /&gt;
&lt;br /&gt;
	local text = external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,&lt;br /&gt;
		prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode,&lt;br /&gt;
		access = access});&lt;br /&gt;
	&lt;br /&gt;
	if 19 ~= id:len() then&lt;br /&gt;
		err_type = cfg.err_msg_supl.length;&lt;br /&gt;
	else&lt;br /&gt;
		year = id:match (&amp;quot;^(%d%d%d%d)[%a][%w&amp;amp;%.][%w&amp;amp;%.][%w&amp;amp;%.][%w.]+[%a%.]$&amp;quot;);&lt;br /&gt;
		if not year then														-- if nil then no pattern match&lt;br /&gt;
			err_type = cfg.err_msg_supl.value;									-- so value error&lt;br /&gt;
		else&lt;br /&gt;
			local next_year = tonumber (os.date (&#039;%Y&#039;)) + 1;					-- get the current year as a number and add one for next year&lt;br /&gt;
			year = tonumber (year);												-- convert year portion of bibcode to a number&lt;br /&gt;
			if (1000 &amp;gt; year) or (year &amp;gt; next_year) then&lt;br /&gt;
				err_type = cfg.err_msg_supl.year;								-- year out of bounds&lt;br /&gt;
			end&lt;br /&gt;
			if id:find(&#039;&amp;amp;%.&#039;) then&lt;br /&gt;
				err_type = cfg.err_msg_supl.journal;							-- journal abbreviation must not have &#039;&amp;amp;.&#039; (if it does it&#039;s missing a letter)&lt;br /&gt;
			end&lt;br /&gt;
			if id:match (&#039;.........%.tmp%.&#039;) then								-- temporary bibcodes when positions 10–14 are &#039;.tmp.&#039;&lt;br /&gt;
				set_message (&#039;maint_bibcode&#039;);&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	if is_set (err_type) and not ignore_invalid then							-- if there was an error detected and accept-as-written markup not used&lt;br /&gt;
		set_message (&#039;err_bad_bibcode&#039;, {err_type});&lt;br /&gt;
		options.coins_list_t[&#039;BIBCODE&#039;] = nil;									-- when error, unset so not included in COinS&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	return text;&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[--------------------------&amp;lt; B I O R X I V &amp;gt;-----------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
Format bioRxiv ID and do simple error checking.  Before 2019-12-11, biorXiv IDs were 10.1101/ followed by exactly&lt;br /&gt;
6 digits.  After 2019-12-11, biorXiv IDs retained the six-digit identifier but prefixed that with a yyyy.mm.dd. &lt;br /&gt;
date and suffixed with an optional version identifier.&lt;br /&gt;
&lt;br /&gt;
The bioRxiv ID is the string of characters:&lt;br /&gt;
	https://doi.org/10.1101/078733 -&amp;gt; 10.1101/078733&lt;br /&gt;
or a date followed by a six-digit number followed by an optional version indicator &#039;v&#039; and one or more digits:&lt;br /&gt;
	https://www.biorxiv.org/content/10.1101/2019.12.11.123456v2 -&amp;gt; 10.1101/2019.12.11.123456v2&lt;br /&gt;
	&lt;br /&gt;
see https://www.biorxiv.org/about-biorxiv&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function biorxiv (options)&lt;br /&gt;
	local id = options.id;&lt;br /&gt;
	local handler = options.handler;&lt;br /&gt;
	local err_msg = true;														-- flag; assume that there will be an error&lt;br /&gt;
	&lt;br /&gt;
	local patterns = {&lt;br /&gt;
		&#039;^10%.1101/%d%d%d%d%d%d$&#039;,												-- simple 6-digit identifier (before 2019-12-11)&lt;br /&gt;
		&#039;^10%.1101/(20%d%d)%.(%d%d)%.(%d%d)%.%d%d%d%d%d%dv%d+$&#039;,				-- y.m.d. date + 6-digit identifier + version (after 2019-12-11)&lt;br /&gt;
		&#039;^10%.1101/(20%d%d)%.(%d%d)%.(%d%d)%.%d%d%d%d%d%d$&#039;,					-- y.m.d. date + 6-digit identifier (after 2019-12-11)&lt;br /&gt;
		}&lt;br /&gt;
	&lt;br /&gt;
	for _, pattern in ipairs (patterns) do										-- spin through the patterns looking for a match&lt;br /&gt;
		if id:match (pattern) then&lt;br /&gt;
			local y, m, d = id:match (pattern);									-- found a match, attempt to get year, month and date from the identifier&lt;br /&gt;
&lt;br /&gt;
			if m then															-- m is nil when id is the six-digit form&lt;br /&gt;
				if not is_valid_rxiv_date (y, m, d, &#039;b&#039;) then					-- validate the encoded date; &#039;b&#039; for biorxiv limit&lt;br /&gt;
					break;														-- date fail; break out early so we don&#039;t unset the error message&lt;br /&gt;
				end&lt;br /&gt;
			end&lt;br /&gt;
			err_msg = nil;														-- we found a match so unset the error message&lt;br /&gt;
			break;																-- and done&lt;br /&gt;
		end&lt;br /&gt;
	end																			-- err_cat remains set here when no match&lt;br /&gt;
&lt;br /&gt;
	if err_msg then&lt;br /&gt;
		options.coins_list_t[&#039;BIORXIV&#039;] = nil;									-- when error, unset so not included in COinS&lt;br /&gt;
		set_message (&#039;err_bad_biorxiv&#039;);										-- and set the error message&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,&lt;br /&gt;
			prefix = handler.prefix, id = id, separator = handler.separator,&lt;br /&gt;
			encode = handler.encode, access = handler.access});&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[--------------------------&amp;lt; C I T E S E E R X &amp;gt;------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
CiteSeerX use their own notion of &amp;quot;doi&amp;quot; (not to be confused with the identifiers resolved via doi.org).&lt;br /&gt;
&lt;br /&gt;
The description of the structure of this identifier can be found at Help_talk:Citation_Style_1/Archive_26#CiteSeerX_id_structure&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function citeseerx (options)&lt;br /&gt;
	local id = options.id;&lt;br /&gt;
	local handler = options.handler;&lt;br /&gt;
	local matched;&lt;br /&gt;
&lt;br /&gt;
	local text = external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,&lt;br /&gt;
		prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode,&lt;br /&gt;
		access = handler.access});&lt;br /&gt;
	&lt;br /&gt;
	matched = id:match (&amp;quot;^10%.1%.1%.[1-9]%d?%d?%d?%.[1-9]%d?%d?%d?$&amp;quot;);&lt;br /&gt;
	if not matched then&lt;br /&gt;
		set_message (&#039;err_bad_citeseerx&#039; );&lt;br /&gt;
		options.coins_list_t[&#039;CITESEERX&#039;] = nil;								-- when error, unset so not included in COinS&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	return text;&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[--------------------------&amp;lt; D O I &amp;gt;------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
Formats a DOI and checks for DOI errors.&lt;br /&gt;
&lt;br /&gt;
DOI names contain two parts: prefix and suffix separated by a forward slash.&lt;br /&gt;
	Prefix: directory indicator &#039;10.&#039; followed by a registrant code&lt;br /&gt;
	Suffix: character string of any length chosen by the registrant&lt;br /&gt;
&lt;br /&gt;
This function checks a DOI name for: prefix/suffix.  If the DOI name contains spaces or endashes, or, if it ends&lt;br /&gt;
with a period or a comma, this function will emit a bad_doi error message.&lt;br /&gt;
&lt;br /&gt;
DOI names are case-insensitive and can incorporate any printable Unicode characters so the test for spaces, endash,&lt;br /&gt;
and terminal punctuation may not be technically correct but it appears, that in practice these characters are rarely&lt;br /&gt;
if ever used in DOI names.&lt;br /&gt;
&lt;br /&gt;
https://www.doi.org/doi_handbook/2_Numbering.html				-- 2.2 Syntax of a DOI name&lt;br /&gt;
https://www.doi.org/doi_handbook/2_Numbering.html#2.2.2			-- 2.2.2 DOI prefix&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function doi (options)&lt;br /&gt;
	local id = options.id;&lt;br /&gt;
	local inactive = options.DoiBroken&lt;br /&gt;
	local access = options.access;&lt;br /&gt;
	local ignore_invalid = options.accept;&lt;br /&gt;
	local handler = options.handler;&lt;br /&gt;
	local err_flag;&lt;br /&gt;
&lt;br /&gt;
	local function is_extended_free (registrant, id)							-- local function to check those few registrants that are mixed; identifiable by the doi suffix &amp;lt;incipit&amp;gt;&lt;br /&gt;
		if cfg.extended_registrants_t[registrant] then							-- if this registrant has known free-to-read extentions&lt;br /&gt;
			for _, incipit in ipairs (cfg.extended_registrants_t[registrant]) do	-- loop through the registrant&#039;s incipits&lt;br /&gt;
				if string.find (id, incipit, 1, true) then						-- if found&lt;br /&gt;
					return true;&lt;br /&gt;
				end&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	local text;&lt;br /&gt;
	if is_set (inactive) then&lt;br /&gt;
		local inactive_year = inactive:match(&amp;quot;%d%d%d%d&amp;quot;);						-- try to get the year portion from the inactive date&lt;br /&gt;
		local inactive_month, good;&lt;br /&gt;
&lt;br /&gt;
		if is_set (inactive_year) then&lt;br /&gt;
			if 4 &amp;lt; inactive:len() then											-- inactive date has more than just a year (could be anything)&lt;br /&gt;
				local lang_obj = mw.getContentLanguage();						-- get a language object for this wiki&lt;br /&gt;
				good, inactive_month = pcall (lang_obj.formatDate, lang_obj, &#039;F&#039;, inactive);	-- try to get the month name from the inactive date&lt;br /&gt;
				if not good then&lt;br /&gt;
					inactive_month = nil;										-- something went wrong so make sure this is unset&lt;br /&gt;
				end&lt;br /&gt;
			end&lt;br /&gt;
		end																		-- otherwise, |doi-broken-date= has something but it isn&#039;t a date&lt;br /&gt;
		&lt;br /&gt;
		if is_set (inactive_year) and is_set (inactive_month) then&lt;br /&gt;
			set_message (&#039;maint_doi_inactive_dated&#039;, {inactive_year, inactive_month, &#039; &#039;});&lt;br /&gt;
		elseif is_set (inactive_year) then&lt;br /&gt;
			set_message (&#039;maint_doi_inactive_dated&#039;, {inactive_year, &#039;&#039;, &#039;&#039;});&lt;br /&gt;
		else&lt;br /&gt;
			set_message (&#039;maint_doi_inactive&#039;);&lt;br /&gt;
		end&lt;br /&gt;
		inactive = &amp;quot; (&amp;quot; .. cfg.messages[&#039;inactive&#039;] .. &#039; &#039; .. inactive .. &#039;)&#039;;&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	local registrant = mw.ustring.match (id, &#039;^10%.([^/]+)/[^%s–]-[^%.,]$&#039;);	-- registrant set when DOI has the proper basic form&lt;br /&gt;
&lt;br /&gt;
	local registrant_err_patterns = {											-- these patterns are for code ranges that are not supported &lt;br /&gt;
		&#039;^[^1-3]%d%d%d%d%.%d+$&#039;,												-- 5 digits with subcode (0xxxx, 40000+); accepts: 10000–39999&lt;br /&gt;
		&#039;^[^1-6]%d%d%d%d$&#039;,														-- 5 digits without subcode (0xxxx, 60000+); accepts: 10000–69999&lt;br /&gt;
		&#039;^[^1-9]%d%d%d%.%d+$&#039;,												-- 4 digits with subcode (0xxx); accepts: 1000–9999&lt;br /&gt;
		&#039;^[^1-9]%d%d%d$&#039;,														-- 4 digits without subcode (0xxx); accepts: 1000–9999&lt;br /&gt;
		&#039;^%d%d%d%d%d%d+&#039;,														-- 6 or more digits&lt;br /&gt;
		&#039;^%d%d?%d?$&#039;,															-- less than 4 digits without subcode (3 digits with subcode is legitimate)&lt;br /&gt;
		&#039;^%d%d?%.[%d%.]+&#039;,														-- 1 or 2 digits with subcode&lt;br /&gt;
		&#039;^5555$&#039;,																-- test registrant will never resolve&lt;br /&gt;
		&#039;[^%d%.]&#039;,																-- any character that isn&#039;t a digit or a dot&lt;br /&gt;
		}&lt;br /&gt;
&lt;br /&gt;
	if not ignore_invalid then&lt;br /&gt;
		if registrant then														-- when DOI has proper form&lt;br /&gt;
			for i, pattern in ipairs (registrant_err_patterns) do				-- spin through error patterns&lt;br /&gt;
				if registrant:match (pattern) then								-- to validate registrant codes&lt;br /&gt;
					err_flag = set_message (&#039;err_bad_doi&#039;);						-- when found, mark this DOI as bad&lt;br /&gt;
					break;														-- and done&lt;br /&gt;
				end&lt;br /&gt;
			end&lt;br /&gt;
		else&lt;br /&gt;
			err_flag = set_message (&#039;err_bad_doi&#039;);								-- invalid directory or malformed&lt;br /&gt;
		end&lt;br /&gt;
	else&lt;br /&gt;
		set_message (&#039;maint_doi_ignore&#039;);&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	if err_flag then&lt;br /&gt;
		options.coins_list_t[&#039;DOI&#039;] = nil;										-- when error, unset so not included in COinS&lt;br /&gt;
	else&lt;br /&gt;
		if not access and (cfg.known_free_doi_registrants_t[registrant] or is_extended_free (registrant, id)) then		-- |doi-access=free not set and &amp;lt;registrant&amp;gt; is known to be free&lt;br /&gt;
			set_message (&#039;maint_doi_unflagged_free&#039;);							-- set a maint cat&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	text = external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,&lt;br /&gt;
		prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode, access = access,&lt;br /&gt;
		auto_link = not (err_flag or is_set (inactive) or ignore_invalid) and &#039;doi&#039; or nil -- do not auto-link when |doi-broken-date= has a value or when there is a DOI error or (to play it safe, after all, auto-linking is not essential) when invalid DOIs are ignored&lt;br /&gt;
		}) .. (inactive or &#039;&#039;);&lt;br /&gt;
&lt;br /&gt;
	return text;&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[--------------------------&amp;lt; H D L &amp;gt;------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
Formats an HDL with minor error checking.&lt;br /&gt;
&lt;br /&gt;
HDL names contain two parts: prefix and suffix separated by a forward slash.&lt;br /&gt;
	Prefix: character string using any character in the UCS-2 character set except &#039;/&#039;&lt;br /&gt;
	Suffix: character string of any length using any character in the UCS-2 character set chosen by the registrant&lt;br /&gt;
&lt;br /&gt;
This function checks a HDL name for: prefix/suffix.  If the HDL name contains spaces, endashes, or, if it ends&lt;br /&gt;
with a period or a comma, this function will emit a bad_hdl error message.&lt;br /&gt;
&lt;br /&gt;
HDL names are case-insensitive and can incorporate any printable Unicode characters so the test for endashes and&lt;br /&gt;
terminal punctuation may not be technically correct but it appears, that in practice these characters are rarely&lt;br /&gt;
if ever used in HDLs.&lt;br /&gt;
&lt;br /&gt;
Query string parameters are named here: https://www.handle.net/proxy_servlet.html.  query strings are not displayed&lt;br /&gt;
but since &#039;?&#039; is an allowed character in an HDL, &#039;?&#039; followed by one of the query parameters is the only way we&lt;br /&gt;
have to detect the query string so that it isn&#039;t URL-encoded with the rest of the identifier.&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function hdl (options)&lt;br /&gt;
	local id = options.id;&lt;br /&gt;
	local access = options.access;&lt;br /&gt;
	local handler = options.handler;&lt;br /&gt;
	local query_params = {														-- list of known query parameters from https://www.handle.net/proxy_servlet.html&lt;br /&gt;
		&#039;noredirect&#039;,&lt;br /&gt;
		&#039;ignore_aliases&#039;,&lt;br /&gt;
		&#039;auth&#039;,&lt;br /&gt;
		&#039;cert&#039;,&lt;br /&gt;
		&#039;index&#039;,&lt;br /&gt;
		&#039;type&#039;,&lt;br /&gt;
		&#039;urlappend&#039;,&lt;br /&gt;
		&#039;locatt&#039;,&lt;br /&gt;
		&#039;action&#039;,&lt;br /&gt;
		}&lt;br /&gt;
	&lt;br /&gt;
	local hdl, suffix, param = id:match (&#039;(.-)(%?(%a+).+)$&#039;);					-- look for query string&lt;br /&gt;
	local found;&lt;br /&gt;
&lt;br /&gt;
	if hdl then																	-- when there are query strings, this is the handle identifier portion&lt;br /&gt;
		for _, q in ipairs (query_params) do									-- spin through the list of query parameters&lt;br /&gt;
			if param:match (&#039;^&#039; .. q) then										-- if the query string begins with one of the parameters&lt;br /&gt;
				found = true;													-- announce a find&lt;br /&gt;
				break;															-- and stop looking&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	if found then&lt;br /&gt;
		id = hdl;																-- found so replace id with the handle portion; this will be URL-encoded, suffix will not&lt;br /&gt;
	else&lt;br /&gt;
		suffix = &#039;&#039;;															-- make sure suffix is empty string for concatenation else&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	local text = external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,&lt;br /&gt;
			prefix = handler.prefix, id = id, suffix = suffix, separator = handler.separator, encode = handler.encode, access = access})&lt;br /&gt;
&lt;br /&gt;
	if nil == id:match(&amp;quot;^[^%s–]-/[^%s–]-[^%.,]$&amp;quot;) then							-- HDL must contain a forward slash, must not contain spaces, endashes, and must not end with period or comma&lt;br /&gt;
		set_message (&#039;err_bad_hdl&#039; );&lt;br /&gt;
		options.coins_list_t[&#039;HDL&#039;] = nil;										-- when error, unset so not included in COinS&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	return text;&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[--------------------------&amp;lt; I S B N &amp;gt;----------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
Determines whether an ISBN string is valid&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function isbn (options)&lt;br /&gt;
	local isbn_str = options.id;&lt;br /&gt;
	local ignore_invalid = options.accept;&lt;br /&gt;
	local handler = options.handler;&lt;br /&gt;
&lt;br /&gt;
	local function return_result (check, err_type)								-- local function to handle the various returns&lt;br /&gt;
		local ISBN = internal_link_id ({link = handler.link, label = handler.label, redirect = handler.redirect,&lt;br /&gt;
						prefix = handler.prefix, id = isbn_str, separator = handler.separator});&lt;br /&gt;
		if ignore_invalid then													-- if ignoring ISBN errors&lt;br /&gt;
			set_message (&#039;maint_isbn_ignore&#039;);									-- add a maint category even when there is no error&lt;br /&gt;
		else																	-- here when not ignoring&lt;br /&gt;
			if not check then													-- and there is an error&lt;br /&gt;
				options.coins_list_t[&#039;ISBN&#039;] = nil;								-- when error, unset so not included in COinS&lt;br /&gt;
				set_message (&#039;err_bad_isbn&#039;, err_type);							-- set an error message&lt;br /&gt;
				return ISBN;										 			-- return id text&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
		return ISBN;															-- return id text&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	if nil ~= isbn_str:match (&#039;[^%s-0-9X]&#039;) then&lt;br /&gt;
		return return_result (false, cfg.err_msg_supl.char);					-- fail if isbn_str contains anything but digits, hyphens, or the uppercase X&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	local id = isbn_str:gsub (&#039;[%s-]&#039;, &#039;&#039;);										-- remove hyphens and whitespace&lt;br /&gt;
&lt;br /&gt;
	local len = id:len();&lt;br /&gt;
 &lt;br /&gt;
	if len ~= 10 and len ~= 13 then&lt;br /&gt;
		return return_result (false, cfg.err_msg_supl.length);					-- fail if incorrect length&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	if len == 10 then&lt;br /&gt;
		if id:match (&#039;^%d*X?$&#039;) == nil then										-- fail if isbn_str has &#039;X&#039; anywhere but last position&lt;br /&gt;
			return return_result (false, cfg.err_msg_supl.form);									&lt;br /&gt;
		end&lt;br /&gt;
		if not is_valid_isxn (id, 10) then										-- test isbn-10 for numerical validity&lt;br /&gt;
			return return_result (false, cfg.err_msg_supl.check);				-- fail if isbn-10 is not numerically valid&lt;br /&gt;
		end&lt;br /&gt;
		if id:find (&#039;^63[01]&#039;) then												-- 630xxxxxxx and 631xxxxxxx are (apparently) not valid isbn group ids but are used by amazon as numeric identifiers (asin)&lt;br /&gt;
			return return_result (false, cfg.err_msg_supl.group);				-- fail if isbn-10 begins with 630/1&lt;br /&gt;
		end&lt;br /&gt;
		return return_result (true, cfg.err_msg_supl.check);					-- pass if isbn-10 is numerically valid&lt;br /&gt;
	else&lt;br /&gt;
		if id:match (&#039;^%d+$&#039;) == nil then&lt;br /&gt;
			return return_result (false, cfg.err_msg_supl.char);				-- fail if ISBN-13 is not all digits&lt;br /&gt;
		end&lt;br /&gt;
		if id:match (&#039;^97[89]%d*$&#039;) == nil then&lt;br /&gt;
			return return_result (false, cfg.err_msg_supl.prefix);				-- fail when ISBN-13 does not begin with 978 or 979&lt;br /&gt;
		end&lt;br /&gt;
		if id:match (&#039;^9790&#039;) then&lt;br /&gt;
			return return_result (false, cfg.err_msg_supl.group);				-- group identifier &#039;0&#039; is reserved to ISMN&lt;br /&gt;
		end&lt;br /&gt;
		return return_result (is_valid_isxn_13 (id), cfg.err_msg_supl.check);&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[--------------------------&amp;lt; A S I N &amp;gt;----------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
Formats a link to Amazon.  Do simple error checking: ASIN must be mix of 10 numeric or uppercase alpha&lt;br /&gt;
characters.  If a mix, first character must be uppercase alpha; if all numeric, ASINs must be 10-digit&lt;br /&gt;
ISBN. If 10-digit ISBN, add a maintenance category so a bot or AWB script can replace |asin= with |isbn=.&lt;br /&gt;
Error message if not 10 characters, if not ISBN-10, if mixed and first character is a digit.&lt;br /&gt;
&lt;br /&gt;
|asin=630....... and |asin=631....... are (apparently) not a legitimate ISBN though it checksums as one; these&lt;br /&gt;
do not cause this function to emit the maint_asin message&lt;br /&gt;
&lt;br /&gt;
This function is positioned here because it calls isbn()&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function asin (options)&lt;br /&gt;
	local id = options.id;&lt;br /&gt;
	local domain = options.ASINTLD;&lt;br /&gt;
	&lt;br /&gt;
	local err_flag;&lt;br /&gt;
&lt;br /&gt;
	if not id:match(&amp;quot;^[%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u]$&amp;quot;) then&lt;br /&gt;
		err_flag = set_message (&#039;err_bad_asin&#039;);								-- ASIN is not a mix of 10 uppercase alpha and numeric characters&lt;br /&gt;
	else&lt;br /&gt;
		if id:match(&amp;quot;^%d%d%d%d%d%d%d%d%d[%dX]$&amp;quot;) then							-- if 10-digit numeric (or 9 digits with terminal X)&lt;br /&gt;
			if is_valid_isxn (id, 10) then										-- see if ASIN value is or validates as ISBN-10&lt;br /&gt;
				if not id:find (&#039;^63[01]&#039;) then									-- 630xxxxxxx and 631xxxxxxx are (apparently) not a valid isbn prefixes but are used by amazon as a numeric identifier&lt;br /&gt;
					err_flag = set_message (&#039;err_bad_asin&#039;);					-- ASIN has ISBN-10 form but begins with something other than 630/1 so probably an isbn &lt;br /&gt;
				end&lt;br /&gt;
			elseif not is_set (err_flag) then&lt;br /&gt;
				err_flag = set_message (&#039;err_bad_asin&#039;);						-- ASIN is not ISBN-10&lt;br /&gt;
			end&lt;br /&gt;
		elseif not id:match(&amp;quot;^%u[%d%u]+$&amp;quot;) then&lt;br /&gt;
			err_flag = set_message (&#039;err_bad_asin&#039;);							-- asin doesn&#039;t begin with uppercase alpha&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	if (not is_set (domain)) or in_array (domain, {&#039;us&#039;}) then					-- default: United States&lt;br /&gt;
		domain = &amp;quot;com&amp;quot;;&lt;br /&gt;
	elseif in_array (domain, {&#039;jp&#039;, &#039;uk&#039;}) then									-- Japan, United Kingdom&lt;br /&gt;
		domain = &amp;quot;co.&amp;quot; .. domain;&lt;br /&gt;
	elseif in_array (domain, {&#039;z.cn&#039;}) then 									-- China&lt;br /&gt;
		domain = &amp;quot;cn&amp;quot;;&lt;br /&gt;
	elseif in_array (domain, {&#039;au&#039;, &#039;br&#039;, &#039;mx&#039;, &#039;sg&#039;, &#039;tr&#039;}) then				-- Australia, Brazil, Mexico, Singapore, Turkey&lt;br /&gt;
		domain = &amp;quot;com.&amp;quot; .. domain;&lt;br /&gt;
	elseif not in_array (domain, {&#039;ae&#039;, &#039;ca&#039;, &#039;cn&#039;, &#039;de&#039;, &#039;es&#039;, &#039;fr&#039;, &#039;in&#039;, &#039;it&#039;, &#039;nl&#039;, &#039;pl&#039;, &#039;sa&#039;, &#039;se&#039;, &#039;co.jp&#039;, &#039;co.uk&#039;, &#039;com&#039;, &#039;com.au&#039;, &#039;com.br&#039;, &#039;com.mx&#039;, &#039;com.sg&#039;, &#039;com.tr&#039;}) then -- Arabic Emirates, Canada, China, Germany, Spain, France, Indonesia, Italy, Netherlands, Poland, Saudi Arabia, Sweden (as of 2021-03 Austria (.at), Liechtenstein (.li) and Switzerland (.ch) still redirect to the German site (.de) with special settings, so don&#039;t maintain local ASINs for them)&lt;br /&gt;
		err_flag = set_message (&#039;err_bad_asin_tld&#039;);							-- unsupported asin-tld value&lt;br /&gt;
	end&lt;br /&gt;
	local handler = options.handler;&lt;br /&gt;
&lt;br /&gt;
	if not is_set (err_flag) then&lt;br /&gt;
		options.coins_list_t[&#039;ASIN&#039;] = handler.prefix .. domain .. &amp;quot;/dp/&amp;quot; .. id;	-- asin for coins&lt;br /&gt;
	else&lt;br /&gt;
		options.coins_list_t[&#039;ASIN&#039;] = nil;										-- when error, unset so not included in COinS&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,&lt;br /&gt;
		prefix = handler.prefix .. domain .. &amp;quot;/dp/&amp;quot;,&lt;br /&gt;
		id = id, encode = handler.encode, separator = handler.separator})&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[--------------------------&amp;lt; I S M N &amp;gt;----------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
Determines whether an ISMN string is valid.  Similar to ISBN-13, ISMN is 13 digits beginning 979-0-... and uses the&lt;br /&gt;
same check digit calculations.  See https://www.ismn-international.org/download/Web_ISMN_Users_Manual_2008-6.pdf&lt;br /&gt;
section 2, pages 9–12.&lt;br /&gt;
&lt;br /&gt;
ismn value not made part of COinS metadata because we don&#039;t have a url or isn&#039;t a COinS-defined identifier (rft.xxx)&lt;br /&gt;
or an identifier registered at info-uri.info (info:)&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function ismn (options)&lt;br /&gt;
	local id = options.id;&lt;br /&gt;
	local handler = options.handler;&lt;br /&gt;
	local text;&lt;br /&gt;
	local valid_ismn = true;&lt;br /&gt;
	local id_copy;&lt;br /&gt;
&lt;br /&gt;
	id_copy = id;																-- save a copy because this testing is destructive&lt;br /&gt;
	id = id:gsub (&#039;[%s-]&#039;, &#039;&#039;);													-- remove hyphens and white space&lt;br /&gt;
&lt;br /&gt;
	if 13 ~= id:len() or id:match (&amp;quot;^9790%d*$&amp;quot; ) == nil then					-- ISMN must be 13 digits and begin with 9790&lt;br /&gt;
		valid_ismn = false;&lt;br /&gt;
	else&lt;br /&gt;
		valid_ismn=is_valid_isxn_13 (id);										-- validate ISMN&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	--	text = internal_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,		-- use this (or external version) when there is some place to link to&lt;br /&gt;
	--		prefix = handler.prefix, id = id_copy, separator = handler.separator, encode = handler.encode})&lt;br /&gt;
&lt;br /&gt;
	text = table.concat (														-- because no place to link to yet&lt;br /&gt;
		{&lt;br /&gt;
		make_wikilink (link_label_make (handler), handler.label),&lt;br /&gt;
		handler.separator,&lt;br /&gt;
		id_copy&lt;br /&gt;
		});&lt;br /&gt;
&lt;br /&gt;
	if false == valid_ismn then&lt;br /&gt;
		options.coins_list_t[&#039;ISMN&#039;] = nil;										-- when error, unset so not included in COinS; not really necessary here because ismn not made part of COinS&lt;br /&gt;
		set_message (&#039;err_bad_ismn&#039;);											-- create an error message if the ISMN is invalid&lt;br /&gt;
	end &lt;br /&gt;
	&lt;br /&gt;
	return text;&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[--------------------------&amp;lt; I S S N &amp;gt;----------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
Validate and format an ISSN.  This code fixes the case where an editor has included an ISSN in the citation but&lt;br /&gt;
has separated the two groups of four digits with a space.  When that condition occurred, the resulting link looked&lt;br /&gt;
like this:&lt;br /&gt;
&lt;br /&gt;
	|issn=0819 4327 gives: [https://www.worldcat.org/issn/0819 4327 0819 4327]	-- can&#039;t have spaces in an external link&lt;br /&gt;
	&lt;br /&gt;
This code now prevents that by inserting a hyphen at the ISSN midpoint.  It also validates the ISSN for length&lt;br /&gt;
and makes sure that the checkdigit agrees with the calculated value.  Incorrect length (8 digits), characters&lt;br /&gt;
other than 0-9 and X, or checkdigit / calculated value mismatch will all cause a check ISSN error message.  The&lt;br /&gt;
ISSN is always displayed with a hyphen, even if the ISSN was given as a single group of 8 digits.&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function issn (options)&lt;br /&gt;
	local id = options.id;&lt;br /&gt;
	local handler = options.handler;&lt;br /&gt;
	local ignore_invalid = options.accept;&lt;br /&gt;
&lt;br /&gt;
	local issn_copy = id;														-- save a copy of unadulterated ISSN; use this version for display if ISSN does not validate&lt;br /&gt;
	local text;&lt;br /&gt;
	local valid_issn = true;&lt;br /&gt;
&lt;br /&gt;
	id = id:gsub (&#039;[%s-]&#039;, &#039;&#039;);													-- remove hyphens and whitespace&lt;br /&gt;
&lt;br /&gt;
	if 8 ~= id:len() or nil == id:match (&amp;quot;^%d*X?$&amp;quot; ) then						-- validate the ISSN: 8 digits long, containing only 0-9 or X in the last position&lt;br /&gt;
		valid_issn = false;														-- wrong length or improper character&lt;br /&gt;
	else&lt;br /&gt;
		valid_issn = is_valid_isxn (id, 8);										-- validate ISSN&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	if true == valid_issn then&lt;br /&gt;
		id = string.sub (id, 1, 4 ) .. &amp;quot;-&amp;quot; .. string.sub (id, 5 );				-- if valid, display correctly formatted version&lt;br /&gt;
	else&lt;br /&gt;
		id = issn_copy;															-- if not valid, show the invalid ISSN with error message&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	text = external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,&lt;br /&gt;
		prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode})&lt;br /&gt;
&lt;br /&gt;
	if ignore_invalid then&lt;br /&gt;
		set_message (&#039;maint_issn_ignore&#039;);&lt;br /&gt;
	else&lt;br /&gt;
		if false == valid_issn then&lt;br /&gt;
			options.coins_list_t[&#039;ISSN&#039;] = nil;									-- when error, unset so not included in COinS&lt;br /&gt;
			set_message (&#039;err_bad_issn&#039;, (options.hkey == &#039;EISSN&#039;) and &#039;e&#039; or &#039;&#039;);	-- create an error message if the ISSN is invalid&lt;br /&gt;
		end &lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	return text;&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[--------------------------&amp;lt; J F M &amp;gt;-----------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
A numerical identifier in the form nn.nnnn.nn&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function jfm (options)&lt;br /&gt;
	local id = options.id;&lt;br /&gt;
	local handler = options.handler;&lt;br /&gt;
	local id_num;&lt;br /&gt;
&lt;br /&gt;
	id_num = id:match (&#039;^[Jj][Ff][Mm](.*)$&#039;);									-- identifier with jfm prefix; extract identifier&lt;br /&gt;
&lt;br /&gt;
	if is_set (id_num) then&lt;br /&gt;
		set_message (&#039;maint_jfm_format&#039;);&lt;br /&gt;
	else																		-- plain number without JFM prefix&lt;br /&gt;
		id_num = id;															-- if here id does not have prefix&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	if id_num and id_num:match(&#039;^%d%d%.%d%d%d%d%.%d%d$&#039;) then&lt;br /&gt;
		id = id_num;															-- jfm matches pattern&lt;br /&gt;
	else&lt;br /&gt;
		set_message (&#039;err_bad_jfm&#039; );											-- set an error message&lt;br /&gt;
		options.coins_list_t[&#039;JFM&#039;] = nil;										-- when error, unset so not included in COinS&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,&lt;br /&gt;
			prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode});&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[--------------------------&amp;lt; J S T O R &amp;gt;--------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
Format a JSTOR with some error checking&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function jstor (options)&lt;br /&gt;
	local id = options.id;&lt;br /&gt;
	local access = options.access;&lt;br /&gt;
	local handler = options.handler;&lt;br /&gt;
&lt;br /&gt;
	if id:find (&#039;[Jj][Ss][Tt][Oo][Rr]&#039;) or id:find (&#039;^https?://&#039;) or id:find (&#039;%s&#039;) then&lt;br /&gt;
		set_message (&#039;err_bad_jstor&#039;);											-- set an error message&lt;br /&gt;
		options.coins_list_t[&#039;JSTOR&#039;] = nil;									-- when error, unset so not included in COinS&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,&lt;br /&gt;
		prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode, access = access});&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[--------------------------&amp;lt; L C C N &amp;gt;----------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
Format LCCN link and do simple error checking.  LCCN is a character string 8-12 characters long. The length of&lt;br /&gt;
the LCCN dictates the character type of the first 1-3 characters; the rightmost eight are always digits.&lt;br /&gt;
https://oclc-research.github.io/infoURI-Frozen/info-uri.info/info:lccn/reg.html&lt;br /&gt;
&lt;br /&gt;
length = 8 then all digits&lt;br /&gt;
length = 9 then lccn[1] is lowercase alpha&lt;br /&gt;
length = 10 then lccn[1] and lccn[2] are both lowercase alpha or both digits&lt;br /&gt;
length = 11 then lccn[1] is lower case alpha, lccn[2] and lccn[3] are both lowercase alpha or both digits&lt;br /&gt;
length = 12 then lccn[1] and lccn[2] are both lowercase alpha&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function lccn (options)&lt;br /&gt;
	local lccn = options.id;&lt;br /&gt;
	local handler = options.handler;&lt;br /&gt;
	local err_flag;																-- presume that LCCN is valid&lt;br /&gt;
	local id = lccn;															-- local copy of the LCCN&lt;br /&gt;
&lt;br /&gt;
	id = normalize_lccn (id);													-- get canonical form (no whitespace, hyphens, forward slashes)&lt;br /&gt;
	local len = id:len();														-- get the length of the LCCN&lt;br /&gt;
&lt;br /&gt;
	if 8 == len then&lt;br /&gt;
		if id:match(&amp;quot;[^%d]&amp;quot;) then												-- if LCCN has anything but digits (nil if only digits)&lt;br /&gt;
			err_flag = set_message (&#039;err_bad_lccn&#039;);							-- set an error message&lt;br /&gt;
		end&lt;br /&gt;
	elseif 9 == len then														-- LCCN should be adddddddd&lt;br /&gt;
		if nil == id:match(&amp;quot;%l%d%d%d%d%d%d%d%d&amp;quot;) then							-- does it match our pattern?&lt;br /&gt;
			err_flag = set_message (&#039;err_bad_lccn&#039;);							-- set an error message&lt;br /&gt;
		end&lt;br /&gt;
	elseif 10 == len then														-- LCCN should be aadddddddd or dddddddddd&lt;br /&gt;
		if id:match(&amp;quot;[^%d]&amp;quot;) then												-- if LCCN has anything but digits (nil if only digits) ...&lt;br /&gt;
			if nil == id:match(&amp;quot;^%l%l%d%d%d%d%d%d%d%d&amp;quot;) then					-- ... see if it matches our pattern&lt;br /&gt;
				err_flag = set_message (&#039;err_bad_lccn&#039;);						-- no match, set an error message&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
	elseif 11 == len then														-- LCCN should be aaadddddddd or adddddddddd&lt;br /&gt;
		if not (id:match(&amp;quot;^%l%l%l%d%d%d%d%d%d%d%d&amp;quot;) or id:match(&amp;quot;^%l%d%d%d%d%d%d%d%d%d%d&amp;quot;)) then	-- see if it matches one of our patterns&lt;br /&gt;
			err_flag = set_message (&#039;err_bad_lccn&#039;);							-- no match, set an error message&lt;br /&gt;
		end&lt;br /&gt;
	elseif 12 == len then														-- LCCN should be aadddddddddd&lt;br /&gt;
		if not id:match(&amp;quot;^%l%l%d%d%d%d%d%d%d%d%d%d&amp;quot;) then						-- see if it matches our pattern&lt;br /&gt;
			err_flag = set_message (&#039;err_bad_lccn&#039;);							-- no match, set an error message&lt;br /&gt;
		end&lt;br /&gt;
	else&lt;br /&gt;
		err_flag = set_message (&#039;err_bad_lccn&#039;);								-- wrong length, set an error message&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	if not is_set (err_flag) and nil ~= lccn:find (&#039;%s&#039;) then&lt;br /&gt;
		err_flag = set_message (&#039;err_bad_lccn&#039;);								-- lccn contains a space, set an error message&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	if is_set (err_flag) then&lt;br /&gt;
		options.coins_list_t[&#039;LCCN&#039;] = nil;										-- when error, unset so not included in COinS&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,&lt;br /&gt;
			prefix = handler.prefix, id = lccn, separator = handler.separator, encode = handler.encode});&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[--------------------------&amp;lt; M E D R X I V &amp;gt;-----------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
Format medRxiv ID and do simple error checking.  Similar to later bioRxiv IDs, medRxiv IDs are prefixed with a&lt;br /&gt;
yyyy.mm.dd. date and suffixed with an optional version identifier.  Ealiest date accepted is 2020.01.01&lt;br /&gt;
&lt;br /&gt;
The medRxiv ID is a date followed by an eight-digit number followed by an optional version indicator &#039;v&#039; and one or more digits:&lt;br /&gt;
	https://www.medrxiv.org/content/10.1101/2020.11.16.20232009v2 -&amp;gt; 10.1101/2020.11.16.20232009v2&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function medrxiv (options)&lt;br /&gt;
	local id = options.id;&lt;br /&gt;
	local handler = options.handler;&lt;br /&gt;
	local err_msg_flag = true;													-- flag; assume that there will be an error&lt;br /&gt;
&lt;br /&gt;
	local patterns = {&lt;br /&gt;
		&#039;%d%d%d%d%d%d%d%d$&#039;,													-- simple 8-digit identifier; these should be relatively rare&lt;br /&gt;
		&#039;^10%.1101/(20%d%d)%.(%d%d)%.(%d%d)%.%d%d%d%d%d%d%d%dv%d+$&#039;,			-- y.m.d. date + 8-digit identifier + version (2020-01-01 and later)&lt;br /&gt;
		&#039;^10%.1101/(20%d%d)%.(%d%d)%.(%d%d)%.%d%d%d%d%d%d%d%d$&#039;,				-- y.m.d. date + 8-digit identifier (2020-01-01 and later)&lt;br /&gt;
		}&lt;br /&gt;
	&lt;br /&gt;
	for _, pattern in ipairs (patterns) do										-- spin through the patterns looking for a match&lt;br /&gt;
		if id:match (pattern) then&lt;br /&gt;
			local y, m, d = id:match (pattern);									-- found a match, attempt to get year, month and date from the identifier&lt;br /&gt;
&lt;br /&gt;
			if m then															-- m is nil when id is the 8-digit form&lt;br /&gt;
				if not is_valid_rxiv_date (y, m, d, &#039;b&#039;) then					-- validate the encoded date; &#039;b&#039; for medrxiv limit&lt;br /&gt;
					break;														-- date fail; break out early so we don&#039;t unset the error message&lt;br /&gt;
				end&lt;br /&gt;
			end&lt;br /&gt;
			err_msg_flag = nil;													-- we found a match so unset the error message&lt;br /&gt;
			break;																-- and done&lt;br /&gt;
		end&lt;br /&gt;
	end																			-- &amp;lt;err_msg_flag&amp;gt; remains set here when no match&lt;br /&gt;
&lt;br /&gt;
	if err_msg_flag then&lt;br /&gt;
		options.coins_list_t[&#039;MEDRXIV&#039;] = nil;									-- when error, unset so not included in COinS&lt;br /&gt;
		set_message (&#039;err_bad_medrxiv&#039;);										-- and set the error message&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,&lt;br /&gt;
			prefix = handler.prefix, id = id, separator = handler.separator,&lt;br /&gt;
			encode = handler.encode, access = handler.access});&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[--------------------------&amp;lt; M R &amp;gt;--------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
A seven digit number; if not seven digits, zero-fill leading digits to make seven digits.&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function mr (options)&lt;br /&gt;
	local id = options.id;&lt;br /&gt;
	local handler = options.handler;&lt;br /&gt;
	local id_num;&lt;br /&gt;
	local id_len;&lt;br /&gt;
&lt;br /&gt;
	id_num = id:match (&#039;^[Mm][Rr](%d+)$&#039;);										-- identifier with mr prefix&lt;br /&gt;
&lt;br /&gt;
	if is_set (id_num) then&lt;br /&gt;
		set_message (&#039;maint_mr_format&#039;);										-- add maint cat&lt;br /&gt;
	else																		-- plain number without mr prefix&lt;br /&gt;
		id_num = id:match (&#039;^%d+$&#039;);											-- if here id is all digits&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	id_len = id_num and id_num:len() or 0;&lt;br /&gt;
	if (7 &amp;gt;= id_len) and (0 ~= id_len) then&lt;br /&gt;
		id = string.rep (&#039;0&#039;, 7-id_len) .. id_num;								-- zero-fill leading digits&lt;br /&gt;
	else&lt;br /&gt;
		set_message (&#039;err_bad_mr&#039;);												-- set an error message&lt;br /&gt;
		options.coins_list_t[&#039;MR&#039;] = nil;										-- when error, unset so not included in COinS&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,&lt;br /&gt;
			prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode});&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[--------------------------&amp;lt; O C L C &amp;gt;----------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
Validate and format an OCLC ID.  https://www.oclc.org/batchload/controlnumber.en.html {{dead link}}&lt;br /&gt;
archived at: https://web.archive.org/web/20161228233804/https://www.oclc.org/batchload/controlnumber.en.html&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function oclc (options)&lt;br /&gt;
	local id = options.id;&lt;br /&gt;
	local handler = options.handler;&lt;br /&gt;
	local number;&lt;br /&gt;
&lt;br /&gt;
	if id:match(&#039;^ocm%d%d%d%d%d%d%d%d$&#039;) then									-- ocm prefix and 8 digits; 001 field (12 characters)&lt;br /&gt;
		number = id:match(&#039;ocm(%d+)&#039;);											-- get the number&lt;br /&gt;
	elseif id:match(&#039;^ocn%d%d%d%d%d%d%d%d%d$&#039;) then								-- ocn prefix and 9 digits; 001 field (12 characters)&lt;br /&gt;
		number = id:match(&#039;ocn(%d+)&#039;);											-- get the number&lt;br /&gt;
	elseif id:match(&#039;^on%d%d%d%d%d%d%d%d%d%d+$&#039;) then							-- on prefix and 10 or more digits; 001 field (12 characters)&lt;br /&gt;
		number = id:match(&#039;^on(%d%d%d%d%d%d%d%d%d%d+)$&#039;);						-- get the number&lt;br /&gt;
	elseif id:match(&#039;^%(OCoLC%)[1-9]%d*$&#039;) then									-- (OCoLC) prefix and variable number digits; no leading zeros; 035 field&lt;br /&gt;
		number = id:match(&#039;%(OCoLC%)([1-9]%d*)&#039;);								-- get the number&lt;br /&gt;
		if 9 &amp;lt; number:len() then&lt;br /&gt;
			number = nil;														-- constrain to 1 to 9 digits; change this when OCLC issues 10-digit numbers&lt;br /&gt;
		end&lt;br /&gt;
	elseif id:match(&#039;^%d+$&#039;) then												-- no prefix&lt;br /&gt;
		number = id;															-- get the number&lt;br /&gt;
		if tonumber (id) &amp;gt; handler.id_limit then&lt;br /&gt;
			number = nil;														-- unset when id value exceeds the limit&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	if number then																-- proper format&lt;br /&gt;
		id = number;															-- exclude prefix, if any, from external link&lt;br /&gt;
	else&lt;br /&gt;
		set_message (&#039;err_bad_oclc&#039;)											-- add an error message if the id is malformed&lt;br /&gt;
		options.coins_list_t[&#039;OCLC&#039;] = nil;										-- when error, unset so not included in COinS&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,&lt;br /&gt;
		prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode});&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[--------------------------&amp;lt; O P E N L I B R A R Y &amp;gt;--------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
Formats an OpenLibrary link, and checks for associated errors.&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function openlibrary (options)&lt;br /&gt;
	local id = options.id;&lt;br /&gt;
	local access = options.access;&lt;br /&gt;
	local handler = options.handler;&lt;br /&gt;
	local ident, code = id:gsub(&#039;^OL&#039;, &#039;&#039;):match(&amp;quot;^(%d+([AMW]))$&amp;quot;);				-- strip optional OL prefix followed immediately by digits followed by &#039;A&#039;, &#039;M&#039;, or &#039;W&#039;;&lt;br /&gt;
	local err_flag;&lt;br /&gt;
	local prefix = {															-- these are appended to the handler.prefix according to code&lt;br /&gt;
		[&#039;A&#039;]=&#039;authors/OL&#039;,&lt;br /&gt;
		[&#039;M&#039;]=&#039;books/OL&#039;,&lt;br /&gt;
		[&#039;W&#039;]=&#039;works/OL&#039;,&lt;br /&gt;
		[&#039;X&#039;]=&#039;OL&#039;																-- not a code; spoof when &#039;code&#039; in id is invalid&lt;br /&gt;
		};&lt;br /&gt;
&lt;br /&gt;
	if not ident then&lt;br /&gt;
		code = &#039;X&#039;;																-- no code or id completely invalid&lt;br /&gt;
		ident = id;																-- copy id to ident so that we display the flawed identifier&lt;br /&gt;
		err_flag = set_message (&#039;err_bad_ol&#039;);&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	if not is_set (err_flag) then&lt;br /&gt;
		options.coins_list_t[&#039;OL&#039;] = handler.prefix .. prefix[code] .. ident;	-- experiment for ol coins&lt;br /&gt;
	else&lt;br /&gt;
		options.coins_list_t[&#039;OL&#039;] = nil;										-- when error, unset so not included in COinS&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,&lt;br /&gt;
		prefix = handler.prefix .. prefix[code],&lt;br /&gt;
		id = ident, separator = handler.separator, encode = handler.encode,&lt;br /&gt;
		access = access});&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[--------------------------&amp;lt; O S T I &amp;gt;----------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
Format OSTI and do simple error checking. OSTIs are sequential numbers beginning at 1 and counting up.  This&lt;br /&gt;
code checks the OSTI to see that it contains only digits and is less than test_limit specified in the configuration;&lt;br /&gt;
the value in test_limit will need to be updated periodically as more OSTIs are issued.&lt;br /&gt;
&lt;br /&gt;
NB. 1018 is the lowest OSTI number found in the wild (so far) and resolving OK on the OSTI site&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function osti (options)&lt;br /&gt;
	local id = options.id;&lt;br /&gt;
	local access = options.access;&lt;br /&gt;
	local handler = options.handler;&lt;br /&gt;
&lt;br /&gt;
	if id:match(&amp;quot;[^%d]&amp;quot;) then													-- if OSTI has anything but digits&lt;br /&gt;
		set_message (&#039;err_bad_osti&#039;);											-- set an error message&lt;br /&gt;
		options.coins_list_t[&#039;OSTI&#039;] = nil;										-- when error, unset so not included in COinS&lt;br /&gt;
	else																		-- OSTI is only digits&lt;br /&gt;
		local id_num = tonumber (id);											-- convert id to a number for range testing&lt;br /&gt;
		if 1018 &amp;gt; id_num or handler.id_limit &amp;lt; id_num then						-- if OSTI is outside test limit boundaries&lt;br /&gt;
			set_message (&#039;err_bad_osti&#039;);										-- set an error message&lt;br /&gt;
			options.coins_list_t[&#039;OSTI&#039;] = nil;									-- when error, unset so not included in COinS&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,&lt;br /&gt;
			prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode, access = access});&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[--------------------------&amp;lt; P M C &amp;gt;------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
Format a PMC, do simple error checking, and check for embargoed articles.&lt;br /&gt;
&lt;br /&gt;
The embargo parameter takes a date for a value. If the embargo date is in the future the PMC identifier will not&lt;br /&gt;
be linked to the article.  If the embargo date is today or in the past, or if it is empty or omitted, then the&lt;br /&gt;
PMC identifier is linked to the article through the link at cfg.id_handlers[&#039;PMC&#039;].prefix.&lt;br /&gt;
&lt;br /&gt;
PMC embargo date testing is done in function is_embargoed () which is called earlier because when the citation&lt;br /&gt;
has |pmc=&amp;lt;value&amp;gt; but does not have a |url= then |title= is linked with the PMC link.  Function is_embargoed ()&lt;br /&gt;
returns the embargo date if the PMC article is still embargoed, otherwise it returns an empty string.&lt;br /&gt;
&lt;br /&gt;
PMCs are sequential numbers beginning at 1 and counting up.  This code checks the PMC to see that it contains only digits and is less&lt;br /&gt;
than test_limit; the value in local variable test_limit will need to be updated periodically as more PMCs are issued.&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function pmc (options)&lt;br /&gt;
	local id = options.id;&lt;br /&gt;
	local embargo = options.Embargo;											-- TODO: lowercase?&lt;br /&gt;
	local handler = options.handler;&lt;br /&gt;
	local err_flag;&lt;br /&gt;
	local id_num;&lt;br /&gt;
	local text;&lt;br /&gt;
&lt;br /&gt;
	id_num = id:match (&#039;^[Pp][Mm][Cc](%d+)$&#039;);									-- identifier with PMC prefix&lt;br /&gt;
&lt;br /&gt;
	if is_set (id_num) then&lt;br /&gt;
		set_message (&#039;maint_pmc_format&#039;);&lt;br /&gt;
	else																		-- plain number without PMC prefix&lt;br /&gt;
		id_num = id:match (&#039;^%d+$&#039;);											-- if here id is all digits&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	if is_set (id_num) then														-- id_num has a value so test it&lt;br /&gt;
		id_num = tonumber (id_num);												-- convert id_num to a number for range testing&lt;br /&gt;
		if 1 &amp;gt; id_num or handler.id_limit &amp;lt; id_num then							-- if PMC is outside test limit boundaries&lt;br /&gt;
			err_flag = set_message (&#039;err_bad_pmc&#039;);								-- set an error message&lt;br /&gt;
		else&lt;br /&gt;
			id = tostring (id_num);												-- make sure id is a string&lt;br /&gt;
		end&lt;br /&gt;
	else																		-- when id format incorrect&lt;br /&gt;
		err_flag = set_message (&#039;err_bad_pmc&#039;);									-- set an error message&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	if is_set (embargo) and is_set (is_embargoed (embargo)) then				-- is PMC is still embargoed?&lt;br /&gt;
		text = table.concat (													-- still embargoed so no external link&lt;br /&gt;
			{&lt;br /&gt;
			make_wikilink (link_label_make (handler), handler.label),&lt;br /&gt;
			handler.separator,&lt;br /&gt;
			id,&lt;br /&gt;
			});&lt;br /&gt;
	else&lt;br /&gt;
		text = external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,	-- no embargo date or embargo has expired, ok to link to article&lt;br /&gt;
			prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode, access = handler.access,&lt;br /&gt;
			auto_link = not err_flag and &#039;pmc&#039; or nil							-- do not auto-link when PMC has error&lt;br /&gt;
			});&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	if err_flag then&lt;br /&gt;
		options.coins_list_t[&#039;PMC&#039;] = nil;										-- when error, unset so not included in COinS&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	return text;&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[--------------------------&amp;lt; P M I D &amp;gt;----------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
Format PMID and do simple error checking.  PMIDs are sequential numbers beginning at 1 and counting up.  This&lt;br /&gt;
code checks the PMID to see that it contains only digits and is less than test_limit; the value in local variable&lt;br /&gt;
test_limit will need to be updated periodically as more PMIDs are issued.&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function pmid (options)&lt;br /&gt;
	local id = options.id;&lt;br /&gt;
	local handler = options.handler;&lt;br /&gt;
&lt;br /&gt;
	if id:match(&amp;quot;[^%d]&amp;quot;) then													-- if PMID has anything but digits&lt;br /&gt;
		set_message (&#039;err_bad_pmid&#039;);											-- set an error message&lt;br /&gt;
		options.coins_list_t[&#039;PMID&#039;] = nil;										-- when error, unset so not included in COinS&lt;br /&gt;
	else																		-- PMID is only digits&lt;br /&gt;
		local id_num = tonumber (id);											-- convert id to a number for range testing&lt;br /&gt;
		if 1 &amp;gt; id_num or handler.id_limit &amp;lt; id_num then							-- if PMID is outside test limit boundaries&lt;br /&gt;
			set_message (&#039;err_bad_pmid&#039;);										-- set an error message&lt;br /&gt;
			options.coins_list_t[&#039;PMID&#039;] = nil;									-- when error, unset so not included in COinS&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,&lt;br /&gt;
			prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode});&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[--------------------------&amp;lt; R F C &amp;gt;------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
Format RFC and do simple error checking. RFCs are sequential numbers beginning at 1 and counting up.  This&lt;br /&gt;
code checks the RFC to see that it contains only digits and is less than test_limit specified in the configuration;&lt;br /&gt;
the value in test_limit will need to be updated periodically as more RFCs are issued.&lt;br /&gt;
&lt;br /&gt;
An index of all RFCs is here: https://tools.ietf.org/rfc/&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function rfc (options)&lt;br /&gt;
	local id = options.id;&lt;br /&gt;
	local handler = options.handler;&lt;br /&gt;
&lt;br /&gt;
	if id:match(&amp;quot;[^%d]&amp;quot;) then													-- if RFC has anything but digits&lt;br /&gt;
		set_message (&#039;err_bad_rfc&#039;);											-- set an error message&lt;br /&gt;
		options.coins_list_t[&#039;RFC&#039;] = nil;										-- when error, unset so not included in COinS&lt;br /&gt;
	else																		-- RFC is only digits&lt;br /&gt;
		local id_num = tonumber (id);											-- convert id to a number for range testing&lt;br /&gt;
		if 1 &amp;gt; id_num or handler.id_limit &amp;lt; id_num then							-- if RFC is outside test limit boundaries&lt;br /&gt;
			set_message (&#039;err_bad_rfc&#039;);										-- set an error message&lt;br /&gt;
			options.coins_list_t[&#039;RFC&#039;] = nil;									-- when error, unset so not included in COinS&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,&lt;br /&gt;
			prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode, access = handler.access});&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[--------------------------&amp;lt; S 2 C I D &amp;gt;--------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
Format an S2CID, do simple error checking&lt;br /&gt;
&lt;br /&gt;
S2CIDs are sequential numbers beginning at 1 and counting up.  This code checks the S2CID to see that it is only&lt;br /&gt;
digits and is less than test_limit; the value in local variable test_limit will need to be updated periodically&lt;br /&gt;
as more S2CIDs are issued.&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function s2cid (options)&lt;br /&gt;
	local id = options.id;&lt;br /&gt;
	local access = options.access;&lt;br /&gt;
	local handler = options.handler;&lt;br /&gt;
	local id_num;&lt;br /&gt;
	local text;&lt;br /&gt;
	&lt;br /&gt;
	id_num = id:match (&#039;^[1-9]%d*$&#039;);											-- id must be all digits; must not begin with 0; no open access flag&lt;br /&gt;
&lt;br /&gt;
 	if is_set (id_num) then														-- id_num has a value so test it&lt;br /&gt;
		id_num = tonumber (id_num);												-- convert id_num to a number for range testing&lt;br /&gt;
		if handler.id_limit &amp;lt; id_num then										-- if S2CID is outside test limit boundaries&lt;br /&gt;
			set_message (&#039;err_bad_s2cid&#039;);										-- set an error message&lt;br /&gt;
			options.coins_list_t[&#039;S2CID&#039;] = nil;								-- when error, unset so not included in COinS&lt;br /&gt;
		end&lt;br /&gt;
	else																		-- when id format incorrect&lt;br /&gt;
		set_message (&#039;err_bad_s2cid&#039;);											-- set an error message&lt;br /&gt;
		options.coins_list_t[&#039;S2CID&#039;] = nil;									-- when error, unset so not included in COinS&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	text = external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,&lt;br /&gt;
		prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode, access = access});&lt;br /&gt;
&lt;br /&gt;
	return text;&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[--------------------------&amp;lt; S B N &amp;gt;------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
9-digit form of ISBN-10; uses same check-digit validation when SBN is prefixed with an additional &#039;0&#039; to make 10 digits&lt;br /&gt;
&lt;br /&gt;
sbn value not made part of COinS metadata because we don&#039;t have a url or isn&#039;t a COinS-defined identifier (rft.xxx)&lt;br /&gt;
or an identifier registered at info-uri.info (info:)&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function sbn (options)&lt;br /&gt;
	local id = options.id;&lt;br /&gt;
	local ignore_invalid = options.accept;&lt;br /&gt;
	local handler = options.handler;&lt;br /&gt;
	local function return_result (check, err_type)								-- local function to handle the various returns&lt;br /&gt;
		local SBN = internal_link_id ({link = handler.link, label = handler.label, redirect = handler.redirect,&lt;br /&gt;
						prefix = handler.prefix, id = id, separator = handler.separator});&lt;br /&gt;
		if not ignore_invalid then												-- if not ignoring SBN errors&lt;br /&gt;
			if not check then&lt;br /&gt;
				options.coins_list_t[&#039;SBN&#039;] = nil;								-- when error, unset so not included in COinS; not really necessary here because sbn not made part of COinS&lt;br /&gt;
				set_message (&#039;err_bad_sbn&#039;, {err_type});						-- display an error message&lt;br /&gt;
				return SBN; &lt;br /&gt;
			end&lt;br /&gt;
		else&lt;br /&gt;
			set_message (&#039;maint_isbn_ignore&#039;);									-- add a maint category even when there is no error (ToDo: Possibly switch to separate message for SBNs only)&lt;br /&gt;
		end&lt;br /&gt;
		return SBN;&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	if id:match (&#039;[^%s-0-9X]&#039;) then&lt;br /&gt;
		return return_result (false, cfg.err_msg_supl.char);					-- fail if SBN contains anything but digits, hyphens, or the uppercase X&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	local ident = id:gsub (&#039;[%s-]&#039;, &#039;&#039;);										-- remove hyphens and whitespace; they interfere with the rest of the tests&lt;br /&gt;
&lt;br /&gt;
	if  9 ~= ident:len() then&lt;br /&gt;
		return return_result (false, cfg.err_msg_supl.length);					-- fail if incorrect length&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	if ident:match (&#039;^%d*X?$&#039;) == nil then&lt;br /&gt;
		return return_result (false, cfg.err_msg_supl.form);					-- fail if SBN has &#039;X&#039; anywhere but last position&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	return return_result (is_valid_isxn (&#039;0&#039; .. ident, 10), cfg.err_msg_supl.check);&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[--------------------------&amp;lt; S S R N &amp;gt;----------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
Format an SSRN, do simple error checking&lt;br /&gt;
&lt;br /&gt;
SSRNs are sequential numbers beginning at 100? and counting up.  This code checks the SSRN to see that it is&lt;br /&gt;
only digits and is greater than 99 and less than test_limit; the value in local variable test_limit will need&lt;br /&gt;
to be updated periodically as more SSRNs are issued.&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function ssrn (options)&lt;br /&gt;
	local id = options.id;&lt;br /&gt;
	local handler = options.handler;&lt;br /&gt;
	local id_num;&lt;br /&gt;
	local text;&lt;br /&gt;
	&lt;br /&gt;
	id_num = id:match (&#039;^%d+$&#039;);												-- id must be all digits&lt;br /&gt;
&lt;br /&gt;
	if is_set (id_num) then														-- id_num has a value so test it&lt;br /&gt;
		id_num = tonumber (id_num);												-- convert id_num to a number for range testing&lt;br /&gt;
		if 100 &amp;gt; id_num or handler.id_limit &amp;lt; id_num then						-- if SSRN is outside test limit boundaries&lt;br /&gt;
			set_message (&#039;err_bad_ssrn&#039;);										-- set an error message&lt;br /&gt;
			options.coins_list_t[&#039;SSRN&#039;] = nil;									-- when error, unset so not included in COinS&lt;br /&gt;
		end&lt;br /&gt;
	else																		-- when id format incorrect&lt;br /&gt;
		set_message (&#039;err_bad_ssrn&#039;);											-- set an error message&lt;br /&gt;
		options.coins_list_t[&#039;SSRN&#039;] = nil;										-- when error, unset so not included in COinS&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	text = external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,&lt;br /&gt;
		prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode, access = options.access});&lt;br /&gt;
&lt;br /&gt;
	return text;&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[--------------------------&amp;lt; U S E N E T _ I D &amp;gt;------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
Validate and format a usenet message id.  Simple error checking, looks for &#039;id-left@id-right&#039; not enclosed in&lt;br /&gt;
&#039;&amp;lt;&#039; and/or &#039;&amp;gt;&#039; angle brackets.&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function usenet_id (options)&lt;br /&gt;
	local id = options.id;&lt;br /&gt;
	local handler = options.handler;&lt;br /&gt;
&lt;br /&gt;
	local text = external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,&lt;br /&gt;
		prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode})&lt;br /&gt;
 &lt;br /&gt;
	if not id:match(&#039;^.+@.+$&#039;) or not id:match(&#039;^[^&amp;lt;].*[^&amp;gt;]$&#039;) then				-- doesn&#039;t have &#039;@&#039; or has one or first or last character is &#039;&amp;lt; or &#039;&amp;gt;&#039;&lt;br /&gt;
		set_message (&#039;err_bad_usenet_id&#039;)										-- add an error message if the message id is invalid&lt;br /&gt;
		options.coins_list_t[&#039;USENETID&#039;] = nil;									-- when error, unset so not included in COinS&lt;br /&gt;
	end &lt;br /&gt;
	&lt;br /&gt;
	return text;&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[--------------------------&amp;lt; Z B L &amp;gt;-----------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
A numerical identifier in the form nnnn.nnnnn - leading zeros in the first quartet optional&lt;br /&gt;
&lt;br /&gt;
format described here: http://emis.mi.sanu.ac.rs/ZMATH/zmath/en/help/search/&lt;br /&gt;
&lt;br /&gt;
temporary format is apparently eight digits.  Anything else is an error&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function zbl (options)&lt;br /&gt;
	local id = options.id;&lt;br /&gt;
	local handler = options.handler;&lt;br /&gt;
&lt;br /&gt;
	if id:match(&#039;^%d%d%d%d%d%d%d%d$&#039;) then										-- is this identifier using temporary format?&lt;br /&gt;
		set_message (&#039;maint_zbl&#039;);												-- yes, add maint cat&lt;br /&gt;
	elseif not id:match(&#039;^%d?%d?%d?%d%.%d%d%d%d%d$&#039;) then						-- not temporary, is it normal format?&lt;br /&gt;
		set_message (&#039;err_bad_zbl&#039;);											-- no, set an error message&lt;br /&gt;
		options.coins_list_t[&#039;ZBL&#039;] = nil;										-- when error, unset so not included in COinS&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,&lt;br /&gt;
			prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode});&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--============================&amp;lt;&amp;lt; I N T E R F A C E   F U N C T I O N S &amp;gt;&amp;gt;==========================================&lt;br /&gt;
&lt;br /&gt;
--[[--------------------------&amp;lt; E X T R A C T _ I D S &amp;gt;------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
Populates ID table from arguments using configuration settings. Loops through cfg.id_handlers and searches args for&lt;br /&gt;
any of the parameters listed in each cfg.id_handlers[&#039;...&#039;].parameters.  If found, adds the parameter and value to&lt;br /&gt;
the identifier list.  Emits redundant error message if more than one alias exists in args&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function extract_ids (args)&lt;br /&gt;
	local id_list = {};															-- list of identifiers found in args&lt;br /&gt;
	for k, v in pairs (cfg.id_handlers) do										-- k is uppercase identifier name as index to cfg.id_handlers; e.g. cfg.id_handlers[&#039;ISBN&#039;], v is a table&lt;br /&gt;
		v = select_one (args, v.parameters, &#039;err_redundant_parameters&#039; );		-- v.parameters is a table of aliases for k; here we pick one from args if present&lt;br /&gt;
		if is_set (v) then id_list[k] = v; end									-- if found in args, add identifier to our list&lt;br /&gt;
	end&lt;br /&gt;
	return id_list;&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[--------------------------&amp;lt; E X T R A C T _ I D _ A C C E S S _ L E V E L S &amp;gt;--------------------------------------&lt;br /&gt;
&lt;br /&gt;
Fetches custom id access levels from arguments using configuration settings. Parameters which have a predefined access&lt;br /&gt;
level (e.g. arxiv) do not use this function as they are directly rendered as free without using an additional parameter.&lt;br /&gt;
&lt;br /&gt;
returns a table of k/v pairs where k is same as the identifier&#039;s key in cfg.id_handlers and v is the assigned (valid) keyword&lt;br /&gt;
&lt;br /&gt;
access-level values must match the case used in cfg.keywords_lists[&#039;id-access&#039;] (lowercase unless there is some special reason for something else)&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function extract_id_access_levels (args, id_list)&lt;br /&gt;
	local id_accesses_list = {};&lt;br /&gt;
	for k, v in pairs (cfg.id_handlers) do&lt;br /&gt;
		local access_param = v.custom_access;									-- name of identifier&#039;s access-level parameter&lt;br /&gt;
		if is_set (access_param) then&lt;br /&gt;
			local access_level = args[access_param];							-- get the assigned value if there is one&lt;br /&gt;
			if is_set (access_level) then&lt;br /&gt;
				if not in_array (access_level, cfg.keywords_lists[&#039;id-access&#039;]) then	-- exact match required&lt;br /&gt;
					set_message (&#039;err_invalid_param_val&#039;, {access_param, access_level});	&lt;br /&gt;
					access_level = nil;											-- invalid so unset&lt;br /&gt;
				end&lt;br /&gt;
				if not is_set (id_list[k]) then									-- identifier access-level must have a matching identifier&lt;br /&gt;
					set_message (&#039;err_param_access_requires_param&#039;, {k:lower()});	-- parameter name is uppercase in cfg.id_handlers (k); lowercase for error message&lt;br /&gt;
				end&lt;br /&gt;
				id_accesses_list[k] = cfg.keywords_xlate[access_level];			-- get translated keyword&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	return id_accesses_list;&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[--------------------------&amp;lt; B U I L D _ I D _ L I S T &amp;gt;----------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
render the identifiers into a sorted sequence table&lt;br /&gt;
&lt;br /&gt;
&amp;lt;ID_list_coins_t&amp;gt; is a table of k/v pairs where k is same as key in cfg.id_handlers and v is the assigned value&lt;br /&gt;
&amp;lt;options_t&amp;gt; is a table of various k/v option pairs provided in the call to new_build_id_list();&lt;br /&gt;
	modified by	this function and passed to all identifier rendering functions&lt;br /&gt;
&amp;lt;access_levels_t&amp;gt; is a table of k/v pairs where k is same as key in cfg.id_handlers and v is the assigned value (if valid)&lt;br /&gt;
&lt;br /&gt;
returns a sequence table of sorted (by hkey - &#039;handler&#039; key) rendered identifier strings&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function build_id_list (ID_list_coins_t, options_t, access_levels_t)&lt;br /&gt;
	local ID_list_t = {};&lt;br /&gt;
	local accept;&lt;br /&gt;
	local func_map = {															--function map points to functions associated with hkey identifier&lt;br /&gt;
		[&#039;ARXIV&#039;] = arxiv,&lt;br /&gt;
		[&#039;ASIN&#039;] = asin,&lt;br /&gt;
		[&#039;BIBCODE&#039;] = bibcode,&lt;br /&gt;
		[&#039;BIORXIV&#039;] = biorxiv,&lt;br /&gt;
		[&#039;CITESEERX&#039;] = citeseerx,&lt;br /&gt;
		[&#039;DOI&#039;] = doi,&lt;br /&gt;
		[&#039;EISSN&#039;] = issn,&lt;br /&gt;
		[&#039;HDL&#039;] = hdl,&lt;br /&gt;
		[&#039;ISBN&#039;] = isbn,&lt;br /&gt;
		[&#039;ISMN&#039;] = ismn,&lt;br /&gt;
		[&#039;ISSN&#039;] = issn,&lt;br /&gt;
		[&#039;JFM&#039;] = jfm,&lt;br /&gt;
		[&#039;JSTOR&#039;] = jstor,&lt;br /&gt;
		[&#039;LCCN&#039;] = lccn,&lt;br /&gt;
		[&#039;MEDRXIV&#039;] = medrxiv,&lt;br /&gt;
		[&#039;MR&#039;] = mr,&lt;br /&gt;
		[&#039;OCLC&#039;] = oclc,&lt;br /&gt;
		[&#039;OL&#039;] = openlibrary,&lt;br /&gt;
		[&#039;OSTI&#039;] = osti,&lt;br /&gt;
		[&#039;PMC&#039;] = pmc,&lt;br /&gt;
		[&#039;PMID&#039;] = pmid,&lt;br /&gt;
		[&#039;RFC&#039;]  = rfc,&lt;br /&gt;
		[&#039;S2CID&#039;] = s2cid,&lt;br /&gt;
		[&#039;SBN&#039;] = sbn,&lt;br /&gt;
		[&#039;SSRN&#039;] = ssrn,&lt;br /&gt;
		[&#039;USENETID&#039;] = usenet_id,&lt;br /&gt;
		[&#039;ZBL&#039;] = zbl,&lt;br /&gt;
		}&lt;br /&gt;
&lt;br /&gt;
	for hkey, v in pairs (ID_list_coins_t) do&lt;br /&gt;
		v, accept = has_accept_as_written (v);									-- remove accept-as-written markup if present; accept is boolean true when markup removed; false else&lt;br /&gt;
																				-- every function gets the options table with value v and accept boolean&lt;br /&gt;
		options_t.hkey = hkey;													-- ~/Configuration handler key&lt;br /&gt;
		options_t.id = v;														-- add that identifier value to the options table&lt;br /&gt;
		options_t.accept = accept;												-- add the accept boolean flag&lt;br /&gt;
		options_t.access = access_levels_t[hkey];								-- add the access level for those that have an |&amp;lt;identifier-access= parameter&lt;br /&gt;
		options_t.handler = cfg.id_handlers[hkey];&lt;br /&gt;
		options_t.coins_list_t = ID_list_coins_t;								-- pointer to ID_list_coins_t; for |asin= and |ol=; also to keep erroneous values out of the citation&#039;s metadata&lt;br /&gt;
		options_t.coins_list_t[hkey] = v;										-- id value without accept-as-written markup for metadata&lt;br /&gt;
		&lt;br /&gt;
		if options_t.handler.access and not in_array (options_t.handler.access, cfg.keywords_lists[&#039;id-access&#039;]) then&lt;br /&gt;
			error (cfg.messages[&#039;unknown_ID_access&#039;] .. options_t.handler.access);	-- here when handler access key set to a value not listed in list of allowed id access keywords&lt;br /&gt;
		end&lt;br /&gt;
&lt;br /&gt;
		if func_map[hkey] then&lt;br /&gt;
			local id_text = func_map[hkey] (options_t);							-- call the function to get identifier text and any error message&lt;br /&gt;
			table.insert (ID_list_t, {hkey, id_text});							-- add identifier text to the output sequence table&lt;br /&gt;
		else&lt;br /&gt;
			error (cfg.messages[&#039;unknown_ID_key&#039;] .. hkey);						-- here when func_map doesn&#039;t have a function for hkey&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	local function comp (a, b)													-- used by following table.sort()&lt;br /&gt;
		return a[1]:lower() &amp;lt; b[1]:lower();										-- sort by hkey&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	table.sort (ID_list_t, comp);												-- sequence table of tables sort	&lt;br /&gt;
	for k, v in ipairs (ID_list_t) do											-- convert sequence table of tables to simple sequence table of strings&lt;br /&gt;
		ID_list_t[k] = v[2];													-- v[2] is the identifier rendering from the call to the various functions in func_map{}&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	return ID_list_t;&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[--------------------------&amp;lt; O P T I O N S _ C H E C K &amp;gt;----------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
check that certain option parameters have their associated identifier parameters with values&lt;br /&gt;
&lt;br /&gt;
&amp;lt;ID_list_coins_t&amp;gt; is a table of k/v pairs where k is same as key in cfg.id_handlers and v is the assigned value&lt;br /&gt;
&amp;lt;ID_support_t&amp;gt; is a sequence table of tables created in citation0() where each subtable has four elements:&lt;br /&gt;
	[1] is the support parameter&#039;s assigned value; empty string if not set&lt;br /&gt;
	[2] is a text string same as key in cfg.id_handlers&lt;br /&gt;
	[3] is cfg.error_conditions key used to create error message&lt;br /&gt;
	[4] is original ID support parameter name used to create error message&lt;br /&gt;
	&lt;br /&gt;
returns nothing; on error emits an appropriate error message&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function options_check (ID_list_coins_t, ID_support_t)&lt;br /&gt;
	for _, v in ipairs (ID_support_t) do&lt;br /&gt;
		if is_set (v[1]) and not ID_list_coins_t[v[2]] then						-- when support parameter has a value but matching identifier parameter is missing or empty&lt;br /&gt;
			set_message (v[3], (v[4]));											-- emit the appropriate error message&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[--------------------------&amp;lt; I D E N T I F I E R _ L I S T S _ G E T &amp;gt;--------------------------------------&lt;br /&gt;
&lt;br /&gt;
Creates two identifier lists: a k/v table of identifiers and their values to be used locally and for use in the&lt;br /&gt;
COinS metadata, and a sequence table of the rendered identifier strings that will be included in the rendered&lt;br /&gt;
citation.&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function identifier_lists_get (args_t, options_t, ID_support_t)&lt;br /&gt;
	local ID_list_coins_t = extract_ids (args_t);										-- get a table of identifiers and their values for use locally and for use in COinS&lt;br /&gt;
	options_check (ID_list_coins_t, ID_support_t);										-- ID support parameters must have matching identifier parameters &lt;br /&gt;
	local ID_access_levels_t = extract_id_access_levels (args_t, ID_list_coins_t);		-- get a table of identifier access levels&lt;br /&gt;
	local ID_list_t = build_id_list (ID_list_coins_t, options_t, ID_access_levels_t);	-- get a sequence table of rendered identifier strings&lt;br /&gt;
&lt;br /&gt;
	return ID_list_t, ID_list_coins_t;											-- return the tables&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[--------------------------&amp;lt; S E T _ S E L E C T E D _ M O D U L E S &amp;gt;--------------------------------------&lt;br /&gt;
&lt;br /&gt;
Sets local cfg table and imported functions table to same (live or sandbox) as that used by the other modules.&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function set_selected_modules (cfg_table_ptr, utilities_page_ptr)&lt;br /&gt;
	cfg = cfg_table_ptr;&lt;br /&gt;
&lt;br /&gt;
	has_accept_as_written = utilities_page_ptr.has_accept_as_written;			-- import functions from select Module:Citation/CS1/Utilities module&lt;br /&gt;
	is_set = utilities_page_ptr.is_set;								&lt;br /&gt;
	in_array = utilities_page_ptr.in_array;&lt;br /&gt;
	set_message = utilities_page_ptr.set_message;&lt;br /&gt;
	select_one = utilities_page_ptr.select_one;&lt;br /&gt;
	substitute = utilities_page_ptr.substitute;&lt;br /&gt;
	make_wikilink = utilities_page_ptr.make_wikilink;&lt;br /&gt;
&lt;br /&gt;
	z = utilities_page_ptr.z;													-- table of tables in Module:Citation/CS1/Utilities&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[--------------------------&amp;lt; E X P O R T E D   F U N C T I O N S &amp;gt;------------------------------------------&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
return {&lt;br /&gt;
	auto_link_urls = auto_link_urls,											-- table of identifier URLs to be used when auto-linking |title=&lt;br /&gt;
	&lt;br /&gt;
	identifier_lists_get = identifier_lists_get,								-- experiment to replace individual calls to build_id_list(), extract_ids, extract_id_access_levels&lt;br /&gt;
	is_embargoed = is_embargoed;&lt;br /&gt;
	set_selected_modules = set_selected_modules;&lt;br /&gt;
	}&lt;/div&gt;</summary>
		<author><name>Marie</name></author>
	</entry>
	<entry>
		<id>http://project-au.w.kmwc.org/index.php?title=Module:SDcat&amp;diff=2091</id>
		<title>Module:SDcat</title>
		<link rel="alternate" type="text/html" href="http://project-au.w.kmwc.org/index.php?title=Module:SDcat&amp;diff=2091"/>
		<updated>2026-01-16T10:08:54Z</updated>

		<summary type="html">&lt;p&gt;Marie: 1 revision imported&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;--[[&lt;br /&gt;
SDcat&lt;br /&gt;
Module to check whether local short description matches that on Wikidata&lt;br /&gt;
--]]&lt;br /&gt;
&lt;br /&gt;
local p = {}&lt;br /&gt;
&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
--[[&lt;br /&gt;
setCat has the qid of a Wikidata entity passed as |qid=&lt;br /&gt;
(it defaults to the associated qid of the current article if omitted)&lt;br /&gt;
and the local short description passed as |sd=&lt;br /&gt;
It returns a category if there is an associated Wikidata entity.&lt;br /&gt;
It returns one of the following tracking categories, as appropriate:&lt;br /&gt;
* Category:Short description matches Wikidata (case-insensitive)&lt;br /&gt;
* Category:Short description is different from Wikidata&lt;br /&gt;
* Category:Short description with empty Wikidata description&lt;br /&gt;
For testing purposes, a link prefix |lp= may be set to &amp;quot;:&amp;quot; to make the categories visible.&lt;br /&gt;
--]]&lt;br /&gt;
&lt;br /&gt;
-- function exported for use in other modules&lt;br /&gt;
-- (local short description, Wikidata entity-ID, link prefix)&lt;br /&gt;
p._setCat = function(sdesc, itemID, lp)&lt;br /&gt;
	if not mw.wikibase then return nil end&lt;br /&gt;
	if itemID == &amp;quot;&amp;quot; then itemID = nil end&lt;br /&gt;
	-- Wikidata description field&lt;br /&gt;
	local wdesc = (mw.wikibase.getDescription(itemID) or &amp;quot;&amp;quot;):lower()&lt;br /&gt;
	if wdesc == &amp;quot;&amp;quot; then&lt;br /&gt;
		return &amp;quot;[[&amp;quot; .. lp .. &amp;quot;Category:Short description with empty Wikidata description]]&amp;quot;&lt;br /&gt;
	elseif wdesc == sdesc then&lt;br /&gt;
		return &amp;quot;[[&amp;quot; .. lp .. &amp;quot;Category:Short description matches Wikidata]]&amp;quot;&lt;br /&gt;
	else&lt;br /&gt;
		return &amp;quot;[[&amp;quot; .. lp .. &amp;quot;Category:Short description is different from Wikidata]]&amp;quot;&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- function exported for call from #invoke&lt;br /&gt;
p.setCat = function(frame)&lt;br /&gt;
	local args&lt;br /&gt;
	if frame.args.sd then&lt;br /&gt;
		args = frame.args&lt;br /&gt;
	else&lt;br /&gt;
		args = frame:getParent().args&lt;br /&gt;
	end&lt;br /&gt;
	-- local short description&lt;br /&gt;
	local sdesc = mw.text.trim(args.sd or &amp;quot;&amp;quot;):lower()&lt;br /&gt;
	-- Wikidata entity-ID&lt;br /&gt;
	local itemID = mw.text.trim(args.qid or &amp;quot;&amp;quot;)&lt;br /&gt;
	-- link prefix, strip quotes&lt;br /&gt;
	local lp = mw.text.trim(args.lp or &amp;quot;&amp;quot;):gsub(&#039;&amp;quot;&#039;, &#039;&#039;)&lt;br /&gt;
	return p._setCat(sdesc, itemID, lp)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
return p&lt;/div&gt;</summary>
		<author><name>Marie</name></author>
	</entry>
	<entry>
		<id>http://project-au.w.kmwc.org/index.php?title=Module:Wd&amp;diff=2089</id>
		<title>Module:Wd</title>
		<link rel="alternate" type="text/html" href="http://project-au.w.kmwc.org/index.php?title=Module:Wd&amp;diff=2089"/>
		<updated>2026-01-16T10:07:18Z</updated>

		<summary type="html">&lt;p&gt;Marie: 1 revision imported&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;-- Original module located at [[:en:Module:Wd]] and [[:en:Module:Wd/i18n]].&lt;br /&gt;
&lt;br /&gt;
require(&amp;quot;strict&amp;quot;)&lt;br /&gt;
local p = {}&lt;br /&gt;
local module_arg = ...&lt;br /&gt;
local i18n&lt;br /&gt;
local i18nPath&lt;br /&gt;
&lt;br /&gt;
local function loadI18n(aliasesP, frame)&lt;br /&gt;
	local title&lt;br /&gt;
&lt;br /&gt;
	if frame then&lt;br /&gt;
		-- current module invoked by page/template, get its title from frame&lt;br /&gt;
		title = frame:getTitle()&lt;br /&gt;
	else&lt;br /&gt;
		-- current module included by other module, get its title from ...&lt;br /&gt;
		title = module_arg&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	if not i18n then&lt;br /&gt;
		i18nPath = title .. &amp;quot;/i18n&amp;quot;&lt;br /&gt;
		i18n = require(i18nPath).init(aliasesP)&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
p.claimCommands = {&lt;br /&gt;
	property   = &amp;quot;property&amp;quot;,&lt;br /&gt;
	properties = &amp;quot;properties&amp;quot;,&lt;br /&gt;
	qualifier  = &amp;quot;qualifier&amp;quot;,&lt;br /&gt;
	qualifiers = &amp;quot;qualifiers&amp;quot;,&lt;br /&gt;
	reference  = &amp;quot;reference&amp;quot;,&lt;br /&gt;
	references = &amp;quot;references&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
p.generalCommands = {&lt;br /&gt;
	label       = &amp;quot;label&amp;quot;,&lt;br /&gt;
	title       = &amp;quot;title&amp;quot;,&lt;br /&gt;
	description = &amp;quot;description&amp;quot;,&lt;br /&gt;
	alias       = &amp;quot;alias&amp;quot;,&lt;br /&gt;
	aliases     = &amp;quot;aliases&amp;quot;,&lt;br /&gt;
	badge       = &amp;quot;badge&amp;quot;,&lt;br /&gt;
	badges      = &amp;quot;badges&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
p.flags = {&lt;br /&gt;
	linked        = &amp;quot;linked&amp;quot;,&lt;br /&gt;
	short         = &amp;quot;short&amp;quot;,&lt;br /&gt;
	raw           = &amp;quot;raw&amp;quot;,&lt;br /&gt;
	multilanguage = &amp;quot;multilanguage&amp;quot;,&lt;br /&gt;
	unit          = &amp;quot;unit&amp;quot;,&lt;br /&gt;
	-------------&lt;br /&gt;
	preferred     = &amp;quot;preferred&amp;quot;,&lt;br /&gt;
	normal        = &amp;quot;normal&amp;quot;,&lt;br /&gt;
	deprecated    = &amp;quot;deprecated&amp;quot;,&lt;br /&gt;
	best          = &amp;quot;best&amp;quot;,&lt;br /&gt;
	future        = &amp;quot;future&amp;quot;,&lt;br /&gt;
	current       = &amp;quot;current&amp;quot;,&lt;br /&gt;
	former        = &amp;quot;former&amp;quot;,&lt;br /&gt;
	edit          = &amp;quot;edit&amp;quot;,&lt;br /&gt;
	editAtEnd     = &amp;quot;edit@end&amp;quot;,&lt;br /&gt;
	mdy           = &amp;quot;mdy&amp;quot;,&lt;br /&gt;
	single        = &amp;quot;single&amp;quot;,&lt;br /&gt;
	sourced       = &amp;quot;sourced&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
p.args = {&lt;br /&gt;
	eid  = &amp;quot;eid&amp;quot;,&lt;br /&gt;
	page = &amp;quot;page&amp;quot;,&lt;br /&gt;
	date = &amp;quot;date&amp;quot;,&lt;br /&gt;
	globalSiteId = &amp;quot;globalSiteId&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
local aliasesP = {&lt;br /&gt;
	coord                   = &amp;quot;P625&amp;quot;,&lt;br /&gt;
	-----------------------&lt;br /&gt;
	image                   = &amp;quot;P18&amp;quot;,&lt;br /&gt;
	author                  = &amp;quot;P50&amp;quot;,&lt;br /&gt;
	authorNameString        = &amp;quot;P2093&amp;quot;,&lt;br /&gt;
	publisher               = &amp;quot;P123&amp;quot;,&lt;br /&gt;
	importedFrom            = &amp;quot;P143&amp;quot;,&lt;br /&gt;
	wikimediaImportURL      = &amp;quot;P4656&amp;quot;,&lt;br /&gt;
	statedIn                = &amp;quot;P248&amp;quot;,&lt;br /&gt;
	pages                   = &amp;quot;P304&amp;quot;,&lt;br /&gt;
	language                = &amp;quot;P407&amp;quot;,&lt;br /&gt;
	hasPart                 = &amp;quot;P527&amp;quot;,&lt;br /&gt;
	publicationDate         = &amp;quot;P577&amp;quot;,&lt;br /&gt;
	startTime               = &amp;quot;P580&amp;quot;,&lt;br /&gt;
	endTime                 = &amp;quot;P582&amp;quot;,&lt;br /&gt;
	chapter                 = &amp;quot;P792&amp;quot;,&lt;br /&gt;
	retrieved               = &amp;quot;P813&amp;quot;,&lt;br /&gt;
	referenceURL            = &amp;quot;P854&amp;quot;,&lt;br /&gt;
	sectionVerseOrParagraph = &amp;quot;P958&amp;quot;,&lt;br /&gt;
	archiveURL              = &amp;quot;P1065&amp;quot;,&lt;br /&gt;
	title                   = &amp;quot;P1476&amp;quot;,&lt;br /&gt;
	formatterURL            = &amp;quot;P1630&amp;quot;,&lt;br /&gt;
	quote                   = &amp;quot;P1683&amp;quot;,&lt;br /&gt;
	shortName               = &amp;quot;P1813&amp;quot;,&lt;br /&gt;
	definingFormula         = &amp;quot;P2534&amp;quot;,&lt;br /&gt;
	archiveDate             = &amp;quot;P2960&amp;quot;,&lt;br /&gt;
	inferredFrom            = &amp;quot;P3452&amp;quot;,&lt;br /&gt;
	typeOfReference         = &amp;quot;P3865&amp;quot;,&lt;br /&gt;
	column                  = &amp;quot;P3903&amp;quot;,&lt;br /&gt;
	subjectNamedAs          = &amp;quot;P1810&amp;quot;,&lt;br /&gt;
	wikidataProperty        = &amp;quot;P1687&amp;quot;,&lt;br /&gt;
	publishedIn             = &amp;quot;P1433&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
local aliasesQ = {&lt;br /&gt;
	percentage              = &amp;quot;Q11229&amp;quot;,&lt;br /&gt;
	prolepticJulianCalendar = &amp;quot;Q1985786&amp;quot;,&lt;br /&gt;
	citeWeb                 = &amp;quot;Q5637226&amp;quot;,&lt;br /&gt;
	citeQ                   = &amp;quot;Q22321052&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
local parameters = {&lt;br /&gt;
	property  = &amp;quot;%p&amp;quot;,&lt;br /&gt;
	qualifier = &amp;quot;%q&amp;quot;,&lt;br /&gt;
	reference = &amp;quot;%r&amp;quot;,&lt;br /&gt;
	alias     = &amp;quot;%a&amp;quot;,&lt;br /&gt;
	badge     = &amp;quot;%b&amp;quot;,&lt;br /&gt;
	separator = &amp;quot;%s&amp;quot;,&lt;br /&gt;
	general   = &amp;quot;%x&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
local formats = {&lt;br /&gt;
	property              = &amp;quot;%p[%s][%r]&amp;quot;,&lt;br /&gt;
	qualifier             = &amp;quot;%q[%s][%r]&amp;quot;,&lt;br /&gt;
	reference             = &amp;quot;%r&amp;quot;,&lt;br /&gt;
	propertyWithQualifier = &amp;quot;%p[ &amp;lt;span style=\&amp;quot;font-size:85\\%\&amp;quot;&amp;gt;(%q)&amp;lt;/span&amp;gt;][%s][%r]&amp;quot;,&lt;br /&gt;
	alias                 = &amp;quot;%a[%s]&amp;quot;,&lt;br /&gt;
	badge                 = &amp;quot;%b[%s]&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
local hookNames = {              -- {level_1, level_2}&lt;br /&gt;
	[parameters.property]         = {&amp;quot;getProperty&amp;quot;},&lt;br /&gt;
	[parameters.reference]        = {&amp;quot;getReferences&amp;quot;, &amp;quot;getReference&amp;quot;},&lt;br /&gt;
	[parameters.qualifier]        = {&amp;quot;getAllQualifiers&amp;quot;},&lt;br /&gt;
	[parameters.qualifier..&amp;quot;\\d&amp;quot;] = {&amp;quot;getQualifiers&amp;quot;, &amp;quot;getQualifier&amp;quot;},&lt;br /&gt;
	[parameters.alias]            = {&amp;quot;getAlias&amp;quot;},&lt;br /&gt;
	[parameters.badge]            = {&amp;quot;getBadge&amp;quot;}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
-- default value objects, should NOT be mutated but instead copied&lt;br /&gt;
local defaultSeparators = {&lt;br /&gt;
	[&amp;quot;sep&amp;quot;]      = {&amp;quot; &amp;quot;},&lt;br /&gt;
	[&amp;quot;sep%s&amp;quot;]    = {&amp;quot;,&amp;quot;},&lt;br /&gt;
	[&amp;quot;sep%q&amp;quot;]    = {&amp;quot;; &amp;quot;},&lt;br /&gt;
	[&amp;quot;sep%q\\d&amp;quot;] = {&amp;quot;, &amp;quot;},&lt;br /&gt;
	[&amp;quot;sep%r&amp;quot;]    = nil,  -- none&lt;br /&gt;
	[&amp;quot;punc&amp;quot;]     = nil   -- none&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
local rankTable = {&lt;br /&gt;
	[&amp;quot;preferred&amp;quot;]  = 1,&lt;br /&gt;
	[&amp;quot;normal&amp;quot;]     = 2,&lt;br /&gt;
	[&amp;quot;deprecated&amp;quot;] = 3&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
local function replaceAlias(id)&lt;br /&gt;
	if aliasesP[id] then&lt;br /&gt;
		id = aliasesP[id]&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	return id&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function errorText(code, ...)&lt;br /&gt;
	local text = i18n[&amp;quot;errors&amp;quot;][code]&lt;br /&gt;
	if arg then text = mw.ustring.format(text, unpack(arg)) end&lt;br /&gt;
	return text&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function throwError(errorMessage, ...)&lt;br /&gt;
	error(errorText(errorMessage, unpack(arg)))&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function replaceDecimalMark(num)&lt;br /&gt;
	return mw.ustring.gsub(num, &amp;quot;[.]&amp;quot;, i18n[&#039;numeric&#039;][&#039;decimal-mark&#039;], 1)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function padZeros(num, numDigits)&lt;br /&gt;
	local numZeros&lt;br /&gt;
	local negative = false&lt;br /&gt;
&lt;br /&gt;
	if num &amp;lt; 0 then&lt;br /&gt;
		negative = true&lt;br /&gt;
		num = num * -1&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	num = tostring(num)&lt;br /&gt;
	numZeros = numDigits - num:len()&lt;br /&gt;
&lt;br /&gt;
	for _ = 1, numZeros do&lt;br /&gt;
		num = &amp;quot;0&amp;quot;..num&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	if negative then&lt;br /&gt;
		num = &amp;quot;-&amp;quot;..num&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	return num&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function replaceSpecialChar(chr)&lt;br /&gt;
	if chr == &#039;_&#039; then&lt;br /&gt;
		-- replace underscores with spaces&lt;br /&gt;
		return &#039; &#039;&lt;br /&gt;
	else&lt;br /&gt;
		return chr&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function replaceSpecialChars(str)&lt;br /&gt;
	local chr&lt;br /&gt;
	local esc = false&lt;br /&gt;
	local strOut = &amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
	for i = 1, #str do&lt;br /&gt;
		chr = str:sub(i,i)&lt;br /&gt;
&lt;br /&gt;
		if not esc then&lt;br /&gt;
			if chr == &#039;\\&#039; then&lt;br /&gt;
				esc = true&lt;br /&gt;
			else&lt;br /&gt;
				strOut = strOut .. replaceSpecialChar(chr)&lt;br /&gt;
			end&lt;br /&gt;
		else&lt;br /&gt;
			strOut = strOut .. chr&lt;br /&gt;
			esc = false&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	return strOut&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function buildWikilink(target, label)&lt;br /&gt;
	if not label or target == label then&lt;br /&gt;
		return &amp;quot;[[&amp;quot; .. target .. &amp;quot;]]&amp;quot;&lt;br /&gt;
	else&lt;br /&gt;
		return &amp;quot;[[&amp;quot; .. target .. &amp;quot;|&amp;quot; .. label .. &amp;quot;]]&amp;quot;&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- used to make frame.args mutable, to replace #frame.args (which is always 0)&lt;br /&gt;
-- with the actual amount and to simply copy tables&lt;br /&gt;
local function copyTable(tIn)&lt;br /&gt;
	if not tIn then&lt;br /&gt;
		return nil&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	local tOut = {}&lt;br /&gt;
&lt;br /&gt;
	for i, v in pairs(tIn) do&lt;br /&gt;
		tOut[i] = v&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	return tOut&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- used to merge output arrays together;&lt;br /&gt;
-- note that it currently mutates the first input array&lt;br /&gt;
local function mergeArrays(a1, a2)&lt;br /&gt;
	for i = 1, #a2 do&lt;br /&gt;
		a1[#a1 + 1] = a2[i]&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	return a1&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function split(str, del)&lt;br /&gt;
	local out = {}&lt;br /&gt;
	local i, j = str:find(del)&lt;br /&gt;
&lt;br /&gt;
	if i and j then&lt;br /&gt;
		out[1] = str:sub(1, i - 1)&lt;br /&gt;
		out[2] = str:sub(j + 1)&lt;br /&gt;
	else&lt;br /&gt;
		out[1] = str&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	return out&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function parseWikidataURL(url)&lt;br /&gt;
	local id&lt;br /&gt;
&lt;br /&gt;
	if url:match(&#039;^http[s]?://&#039;) then&lt;br /&gt;
		id = split(url, &amp;quot;Q&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
		if id[2] then&lt;br /&gt;
			return &amp;quot;Q&amp;quot; .. id[2]&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	return nil&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function parseDate(dateStr, precision)&lt;br /&gt;
	precision = precision or &amp;quot;d&amp;quot;&lt;br /&gt;
&lt;br /&gt;
	local i, j, index, ptr&lt;br /&gt;
	local parts = {nil, nil, nil}&lt;br /&gt;
&lt;br /&gt;
	if dateStr == nil then&lt;br /&gt;
		return parts[1], parts[2], parts[3]  -- year, month, day&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- &#039;T&#039; for snak values, &#039;/&#039; for outputs with &#039;/Julian&#039; attached&lt;br /&gt;
	i, j = dateStr:find(&amp;quot;[T/]&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
	if i then&lt;br /&gt;
		dateStr = dateStr:sub(1, i-1)&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	local from = 1&lt;br /&gt;
&lt;br /&gt;
	if dateStr:sub(1,1) == &amp;quot;-&amp;quot; then&lt;br /&gt;
		-- this is a negative number, look further ahead&lt;br /&gt;
		from = 2&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	index = 1&lt;br /&gt;
	ptr = 1&lt;br /&gt;
&lt;br /&gt;
	i, j = dateStr:find(&amp;quot;-&amp;quot;, from)&lt;br /&gt;
&lt;br /&gt;
	if i then&lt;br /&gt;
		-- year&lt;br /&gt;
		parts[index] = tonumber(dateStr:sub(ptr, i-1), 10)  -- explicitly give base 10 to prevent error&lt;br /&gt;
&lt;br /&gt;
		if parts[index] == -0 then&lt;br /&gt;
			parts[index] = tonumber(&amp;quot;0&amp;quot;)  -- for some reason, &#039;parts[index] = 0&#039; may actually store &#039;-0&#039;, so parse from string instead&lt;br /&gt;
		end&lt;br /&gt;
&lt;br /&gt;
		if precision == &amp;quot;y&amp;quot; then&lt;br /&gt;
			-- we&#039;re done&lt;br /&gt;
			return parts[1], parts[2], parts[3]  -- year, month, day&lt;br /&gt;
		end&lt;br /&gt;
&lt;br /&gt;
		index = index + 1&lt;br /&gt;
		ptr = i + 1&lt;br /&gt;
&lt;br /&gt;
		i, j = dateStr:find(&amp;quot;-&amp;quot;, ptr)&lt;br /&gt;
&lt;br /&gt;
		if i then&lt;br /&gt;
			-- month&lt;br /&gt;
			parts[index] = tonumber(dateStr:sub(ptr, i-1), 10)&lt;br /&gt;
&lt;br /&gt;
			if precision == &amp;quot;m&amp;quot; then&lt;br /&gt;
				-- we&#039;re done&lt;br /&gt;
				return parts[1], parts[2], parts[3]  -- year, month, day&lt;br /&gt;
			end&lt;br /&gt;
&lt;br /&gt;
			index = index + 1&lt;br /&gt;
			ptr = i + 1&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	if dateStr:sub(ptr) ~= &amp;quot;&amp;quot; then&lt;br /&gt;
		-- day if we have month, month if we have year, or year&lt;br /&gt;
		parts[index] = tonumber(dateStr:sub(ptr), 10)&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	return parts[1], parts[2], parts[3]  -- year, month, day&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function datePrecedesDate(aY, aM, aD, bY, bM, bD)&lt;br /&gt;
	if aY == nil or bY == nil then&lt;br /&gt;
		return nil&lt;br /&gt;
	end&lt;br /&gt;
	aM = aM or 1&lt;br /&gt;
	aD = aD or 1&lt;br /&gt;
	bM = bM or 1&lt;br /&gt;
	bD = bD or 1&lt;br /&gt;
&lt;br /&gt;
	if aY &amp;lt; bY then&lt;br /&gt;
		return true&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	if aY &amp;gt; bY then&lt;br /&gt;
		return false&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	if aM &amp;lt; bM then&lt;br /&gt;
		return true&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	if aM &amp;gt; bM then&lt;br /&gt;
		return false&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	if aD &amp;lt; bD then&lt;br /&gt;
		return true&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	return false&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function getHookName(param, index)&lt;br /&gt;
	if hookNames[param] then&lt;br /&gt;
		return hookNames[param][index]&lt;br /&gt;
	elseif param:len() &amp;gt; 2 then&lt;br /&gt;
		return hookNames[param:sub(1, 2)..&amp;quot;\\d&amp;quot;][index]&lt;br /&gt;
	else&lt;br /&gt;
		return nil&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function alwaysTrue()&lt;br /&gt;
	return true&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- The following function parses a format string.&lt;br /&gt;
--&lt;br /&gt;
-- The example below shows how a parsed string is structured in memory.&lt;br /&gt;
-- Variables other than &#039;str&#039; and &#039;child&#039; are left out for clarity&#039;s sake.&lt;br /&gt;
--&lt;br /&gt;
-- Example:&lt;br /&gt;
-- &amp;quot;A %p B [%s[%q1]] C [%r] D&amp;quot;&lt;br /&gt;
--&lt;br /&gt;
-- Structure:&lt;br /&gt;
-- [&lt;br /&gt;
--   {&lt;br /&gt;
--     str = &amp;quot;A &amp;quot;&lt;br /&gt;
--   },&lt;br /&gt;
--   {&lt;br /&gt;
--     str = &amp;quot;%p&amp;quot;&lt;br /&gt;
--   },&lt;br /&gt;
--   {&lt;br /&gt;
--     str = &amp;quot; B &amp;quot;,&lt;br /&gt;
--     child =&lt;br /&gt;
--     [&lt;br /&gt;
--       {&lt;br /&gt;
--         str = &amp;quot;%s&amp;quot;,&lt;br /&gt;
--         child =&lt;br /&gt;
--         [&lt;br /&gt;
--           {&lt;br /&gt;
--             str = &amp;quot;%q1&amp;quot;&lt;br /&gt;
--           }&lt;br /&gt;
--         ]&lt;br /&gt;
--       }&lt;br /&gt;
--     ]&lt;br /&gt;
--   },&lt;br /&gt;
--   {&lt;br /&gt;
--     str = &amp;quot; C &amp;quot;,&lt;br /&gt;
--     child =&lt;br /&gt;
--     [&lt;br /&gt;
--       {&lt;br /&gt;
--         str = &amp;quot;%r&amp;quot;&lt;br /&gt;
--       }&lt;br /&gt;
--     ]&lt;br /&gt;
--   },&lt;br /&gt;
--   {&lt;br /&gt;
--     str = &amp;quot; D&amp;quot;&lt;br /&gt;
--   }&lt;br /&gt;
-- ]&lt;br /&gt;
--&lt;br /&gt;
local function parseFormat(str)&lt;br /&gt;
	local chr, esc, param, root, cur, prev, new&lt;br /&gt;
	local params = {}&lt;br /&gt;
&lt;br /&gt;
	local function newObject(array)&lt;br /&gt;
		local obj = {}  -- new object&lt;br /&gt;
		obj.str = &amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
		array[#array + 1] = obj  -- array{object}&lt;br /&gt;
		obj.parent = array&lt;br /&gt;
&lt;br /&gt;
		return obj&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	local function endParam()&lt;br /&gt;
		if param &amp;gt; 0 then&lt;br /&gt;
			if cur.str ~= &amp;quot;&amp;quot; then&lt;br /&gt;
				cur.str = &amp;quot;%&amp;quot;..cur.str&lt;br /&gt;
				cur.param = true&lt;br /&gt;
				params[cur.str] = true&lt;br /&gt;
				cur.parent.req[cur.str] = true&lt;br /&gt;
				prev = cur&lt;br /&gt;
				cur = newObject(cur.parent)&lt;br /&gt;
			end&lt;br /&gt;
			param = 0&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	root = {}  -- array&lt;br /&gt;
	root.req = {}&lt;br /&gt;
	cur = newObject(root)&lt;br /&gt;
	prev = nil&lt;br /&gt;
&lt;br /&gt;
	esc = false&lt;br /&gt;
	param = 0&lt;br /&gt;
&lt;br /&gt;
	for i = 1, #str do&lt;br /&gt;
		chr = str:sub(i,i)&lt;br /&gt;
&lt;br /&gt;
		if not esc then&lt;br /&gt;
			if chr == &#039;\\&#039; then&lt;br /&gt;
				endParam()&lt;br /&gt;
				esc = true&lt;br /&gt;
			elseif chr == &#039;%&#039; then&lt;br /&gt;
				endParam()&lt;br /&gt;
				if cur.str ~= &amp;quot;&amp;quot; then&lt;br /&gt;
					cur = newObject(cur.parent)&lt;br /&gt;
				end&lt;br /&gt;
				param = 2&lt;br /&gt;
			elseif chr == &#039;[&#039; then&lt;br /&gt;
				endParam()&lt;br /&gt;
				if prev and cur.str == &amp;quot;&amp;quot; then&lt;br /&gt;
					table.remove(cur.parent)&lt;br /&gt;
					cur = prev&lt;br /&gt;
				end&lt;br /&gt;
				cur.child = {}  -- new array&lt;br /&gt;
				cur.child.req = {}&lt;br /&gt;
				cur.child.parent = cur&lt;br /&gt;
				cur = newObject(cur.child)&lt;br /&gt;
			elseif chr == &#039;]&#039; then&lt;br /&gt;
				endParam()&lt;br /&gt;
				if cur.parent.parent then&lt;br /&gt;
					new = newObject(cur.parent.parent.parent)&lt;br /&gt;
					if cur.str == &amp;quot;&amp;quot; then&lt;br /&gt;
						table.remove(cur.parent)&lt;br /&gt;
					end&lt;br /&gt;
					cur = new&lt;br /&gt;
				end&lt;br /&gt;
			else&lt;br /&gt;
				if param &amp;gt; 1 then&lt;br /&gt;
					param = param - 1&lt;br /&gt;
				elseif param == 1 then&lt;br /&gt;
					if not chr:match(&#039;%d&#039;) then&lt;br /&gt;
						endParam()&lt;br /&gt;
					end&lt;br /&gt;
				end&lt;br /&gt;
&lt;br /&gt;
				cur.str = cur.str .. replaceSpecialChar(chr)&lt;br /&gt;
			end&lt;br /&gt;
		else&lt;br /&gt;
			cur.str = cur.str .. chr&lt;br /&gt;
			esc = false&lt;br /&gt;
		end&lt;br /&gt;
&lt;br /&gt;
		prev = nil&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	endParam()&lt;br /&gt;
&lt;br /&gt;
	-- make sure that at least one required parameter has been defined&lt;br /&gt;
	if not next(root.req) then&lt;br /&gt;
		throwError(&amp;quot;missing-required-parameter&amp;quot;)&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- make sure that the separator parameter &amp;quot;%s&amp;quot; is not amongst the required parameters&lt;br /&gt;
	if root.req[parameters.separator] then&lt;br /&gt;
		throwError(&amp;quot;extra-required-parameter&amp;quot;, parameters.separator)&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	return root, params&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function sortOnRank(claims)&lt;br /&gt;
	local rankPos&lt;br /&gt;
	local ranks = {{}, {}, {}, {}}  -- preferred, normal, deprecated, (default)&lt;br /&gt;
	local sorted = {}&lt;br /&gt;
&lt;br /&gt;
	for _, v in ipairs(claims) do&lt;br /&gt;
		rankPos = rankTable[v.rank] or 4&lt;br /&gt;
		ranks[rankPos][#ranks[rankPos] + 1] = v&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	sorted = ranks[1]&lt;br /&gt;
	sorted = mergeArrays(sorted, ranks[2])&lt;br /&gt;
	sorted = mergeArrays(sorted, ranks[3])&lt;br /&gt;
&lt;br /&gt;
	return sorted&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function isValueInTable(searchedItem, inputTable)&lt;br /&gt;
	for _, item in pairs(inputTable) do&lt;br /&gt;
		if item == searchedItem then&lt;br /&gt;
			return true&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	return false&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local Config = {}&lt;br /&gt;
&lt;br /&gt;
-- allows for recursive calls&lt;br /&gt;
function Config:new()&lt;br /&gt;
	local cfg = {}&lt;br /&gt;
	setmetatable(cfg, self)&lt;br /&gt;
	self.__index = self&lt;br /&gt;
&lt;br /&gt;
	cfg.separators = {&lt;br /&gt;
		-- single value objects wrapped in arrays so that we can pass by reference&lt;br /&gt;
		[&amp;quot;sep&amp;quot;]   = {copyTable(defaultSeparators[&amp;quot;sep&amp;quot;])},&lt;br /&gt;
		[&amp;quot;sep%s&amp;quot;] = {copyTable(defaultSeparators[&amp;quot;sep%s&amp;quot;])},&lt;br /&gt;
		[&amp;quot;sep%q&amp;quot;] = {copyTable(defaultSeparators[&amp;quot;sep%q&amp;quot;])},&lt;br /&gt;
		[&amp;quot;sep%r&amp;quot;] = {copyTable(defaultSeparators[&amp;quot;sep%r&amp;quot;])},&lt;br /&gt;
		[&amp;quot;punc&amp;quot;]  = {copyTable(defaultSeparators[&amp;quot;punc&amp;quot;])}&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	cfg.entity = nil&lt;br /&gt;
	cfg.entityID = nil&lt;br /&gt;
	cfg.propertyID = nil&lt;br /&gt;
	cfg.propertyValue = nil&lt;br /&gt;
	cfg.qualifierIDs = {}&lt;br /&gt;
	cfg.qualifierIDsAndValues = {}&lt;br /&gt;
&lt;br /&gt;
	cfg.bestRank = true&lt;br /&gt;
	cfg.ranks = {true, true, false}  -- preferred = true, normal = true, deprecated = false&lt;br /&gt;
	cfg.foundRank = #cfg.ranks&lt;br /&gt;
	cfg.flagBest = false&lt;br /&gt;
	cfg.flagRank = false&lt;br /&gt;
&lt;br /&gt;
	cfg.periods = {true, true, true}  -- future = true, current = true, former = true&lt;br /&gt;
	cfg.flagPeriod = false&lt;br /&gt;
	cfg.atDate = {parseDate(os.date(&#039;!%Y-%m-%d&#039;))}  -- today as {year, month, day}&lt;br /&gt;
&lt;br /&gt;
	cfg.mdyDate = false&lt;br /&gt;
	cfg.singleClaim = false&lt;br /&gt;
	cfg.sourcedOnly = false&lt;br /&gt;
	cfg.editable = false&lt;br /&gt;
	cfg.editAtEnd = false&lt;br /&gt;
&lt;br /&gt;
	cfg.inSitelinks = false&lt;br /&gt;
&lt;br /&gt;
	cfg.langCode = mw.language.getContentLanguage().code&lt;br /&gt;
	cfg.langName = mw.language.fetchLanguageName(cfg.langCode, cfg.langCode)&lt;br /&gt;
	cfg.langObj = mw.language.new(cfg.langCode)&lt;br /&gt;
&lt;br /&gt;
	cfg.siteID = mw.wikibase.getGlobalSiteId()&lt;br /&gt;
&lt;br /&gt;
	cfg.states = {}&lt;br /&gt;
	cfg.states.qualifiersCount = 0&lt;br /&gt;
	cfg.curState = nil&lt;br /&gt;
&lt;br /&gt;
	cfg.prefetchedRefs = nil&lt;br /&gt;
&lt;br /&gt;
	return cfg&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local State = {}&lt;br /&gt;
&lt;br /&gt;
function State:new(cfg, type)&lt;br /&gt;
	local stt = {}&lt;br /&gt;
	setmetatable(stt, self)&lt;br /&gt;
	self.__index = self&lt;br /&gt;
&lt;br /&gt;
	stt.conf = cfg&lt;br /&gt;
	stt.type = type&lt;br /&gt;
&lt;br /&gt;
	stt.results = {}&lt;br /&gt;
&lt;br /&gt;
	stt.parsedFormat = {}&lt;br /&gt;
	stt.separator = {}&lt;br /&gt;
	stt.movSeparator = {}&lt;br /&gt;
	stt.puncMark = {}&lt;br /&gt;
&lt;br /&gt;
	stt.linked = false&lt;br /&gt;
	stt.rawValue = false&lt;br /&gt;
	stt.shortName = false&lt;br /&gt;
	stt.anyLanguage = false&lt;br /&gt;
	stt.unitOnly = false&lt;br /&gt;
	stt.singleValue = false&lt;br /&gt;
&lt;br /&gt;
	return stt&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- if id == nil then item connected to current page is used&lt;br /&gt;
function Config:getLabel(id, raw, link, short)&lt;br /&gt;
	local label = nil&lt;br /&gt;
	local prefix, title= &amp;quot;&amp;quot;, nil&lt;br /&gt;
&lt;br /&gt;
	if not id then&lt;br /&gt;
		id = mw.wikibase.getEntityIdForCurrentPage()&lt;br /&gt;
&lt;br /&gt;
		if not id then&lt;br /&gt;
			return &amp;quot;&amp;quot;&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	id = id:upper()  -- just to be sure&lt;br /&gt;
&lt;br /&gt;
	if raw then&lt;br /&gt;
		-- check if given id actually exists&lt;br /&gt;
		if mw.wikibase.isValidEntityId(id) and mw.wikibase.entityExists(id) then&lt;br /&gt;
			label = id&lt;br /&gt;
		end&lt;br /&gt;
&lt;br /&gt;
		prefix, title = &amp;quot;d:Special:EntityPage/&amp;quot;, label -- may be nil&lt;br /&gt;
	else&lt;br /&gt;
		-- try short name first if requested&lt;br /&gt;
		if short then&lt;br /&gt;
			label = p._property{aliasesP.shortName, [p.args.eid] = id}  -- get short name&lt;br /&gt;
&lt;br /&gt;
			if label == &amp;quot;&amp;quot; then&lt;br /&gt;
				label = nil&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
&lt;br /&gt;
		-- get label&lt;br /&gt;
		if not label then&lt;br /&gt;
			label = mw.wikibase.getLabel(id)&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	if not label then&lt;br /&gt;
		label = &amp;quot;&amp;quot;&lt;br /&gt;
	elseif link then&lt;br /&gt;
		-- build a link if requested&lt;br /&gt;
		if not title then&lt;br /&gt;
			if id:sub(1,1) == &amp;quot;Q&amp;quot; then&lt;br /&gt;
				title = mw.wikibase.getSitelink(id)&lt;br /&gt;
			elseif id:sub(1,1) == &amp;quot;P&amp;quot; then&lt;br /&gt;
				-- properties have no sitelink, link to Wikidata instead&lt;br /&gt;
				prefix, title = &amp;quot;d:Special:EntityPage/&amp;quot;, id&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
&lt;br /&gt;
		label = mw.text.nowiki(label) -- escape raw label text so it cannot be wikitext markup&lt;br /&gt;
		if title then&lt;br /&gt;
			label = buildWikilink(prefix .. title, label)&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	return label&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function Config:getEditIcon()&lt;br /&gt;
	local value = &amp;quot;&amp;quot;&lt;br /&gt;
	local prefix = &amp;quot;&amp;quot;&lt;br /&gt;
	local front = &amp;quot;&amp;amp;nbsp;&amp;quot;&lt;br /&gt;
	local back = &amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
	if self.entityID:sub(1,1) == &amp;quot;P&amp;quot; then&lt;br /&gt;
		prefix = &amp;quot;Property:&amp;quot;&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	if self.editAtEnd then&lt;br /&gt;
		front = &#039;&amp;lt;span style=&amp;quot;float:&#039;&lt;br /&gt;
&lt;br /&gt;
		if self.langObj:isRTL() then&lt;br /&gt;
			front = front .. &#039;left&#039;&lt;br /&gt;
		else&lt;br /&gt;
			front = front .. &#039;right&#039;&lt;br /&gt;
		end&lt;br /&gt;
&lt;br /&gt;
		front = front .. &#039;&amp;quot;&amp;gt;&#039;&lt;br /&gt;
		back = &#039;&amp;lt;/span&amp;gt;&#039;&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	value = &amp;quot;[[File:OOjs UI icon edit-ltr-progressive.svg|frameless|text-top|10px|alt=&amp;quot; .. i18n[&#039;info&#039;][&#039;edit-on-wikidata&#039;] .. &amp;quot;|link=https://www.wikidata.org/wiki/&amp;quot; .. prefix .. self.entityID .. &amp;quot;?uselang=&amp;quot; .. self.langCode&lt;br /&gt;
&lt;br /&gt;
	if self.propertyID then&lt;br /&gt;
		value = value .. &amp;quot;#&amp;quot; .. self.propertyID&lt;br /&gt;
	elseif self.inSitelinks then&lt;br /&gt;
		value = value .. &amp;quot;#sitelinks-wikipedia&amp;quot;&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	value = value .. &amp;quot;|&amp;quot; .. i18n[&#039;info&#039;][&#039;edit-on-wikidata&#039;] .. &amp;quot;]]&amp;quot;&lt;br /&gt;
&lt;br /&gt;
	return front .. value .. back&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- used to create the final output string when it&#039;s all done, so that for references the&lt;br /&gt;
-- function extensionTag(&amp;quot;ref&amp;quot;, ...) is only called when they really ended up in the final output&lt;br /&gt;
function Config:concatValues(valuesArray)&lt;br /&gt;
	local outString = &amp;quot;&amp;quot;&lt;br /&gt;
	local j, skip&lt;br /&gt;
&lt;br /&gt;
	for i = 1, #valuesArray do&lt;br /&gt;
		-- check if this is a reference&lt;br /&gt;
		if valuesArray[i].refHash then&lt;br /&gt;
			j = i - 1&lt;br /&gt;
			skip = false&lt;br /&gt;
&lt;br /&gt;
			-- skip this reference if it is part of a continuous row of references that already contains the exact same reference&lt;br /&gt;
			while valuesArray[j] and valuesArray[j].refHash do&lt;br /&gt;
				if valuesArray[i].refHash == valuesArray[j].refHash then&lt;br /&gt;
					skip = true&lt;br /&gt;
					break&lt;br /&gt;
				end&lt;br /&gt;
				j = j - 1&lt;br /&gt;
			end&lt;br /&gt;
&lt;br /&gt;
			if not skip then&lt;br /&gt;
				-- add &amp;lt;ref&amp;gt; tag with the reference&#039;s hash as its name (to deduplicate references)&lt;br /&gt;
				outString = outString .. mw.getCurrentFrame():extensionTag(&amp;quot;ref&amp;quot;, valuesArray[i][1], {name = valuesArray[i].refHash})&lt;br /&gt;
			end&lt;br /&gt;
		else&lt;br /&gt;
			outString = outString .. valuesArray[i][1]&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	return outString&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function Config:convertUnit(unit, raw, link, short, unitOnly)&lt;br /&gt;
	local space = &amp;quot; &amp;quot;&lt;br /&gt;
	local label = &amp;quot;&amp;quot;&lt;br /&gt;
	local itemID&lt;br /&gt;
&lt;br /&gt;
	if unit == &amp;quot;&amp;quot; or unit == &amp;quot;1&amp;quot; then&lt;br /&gt;
		return nil&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	if unitOnly then&lt;br /&gt;
		space = &amp;quot;&amp;quot;&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	itemID = parseWikidataURL(unit)&lt;br /&gt;
&lt;br /&gt;
	if itemID then&lt;br /&gt;
		if itemID == aliasesQ.percentage then&lt;br /&gt;
			return &amp;quot;%&amp;quot;&lt;br /&gt;
		else&lt;br /&gt;
			label = self:getLabel(itemID, raw, link, short)&lt;br /&gt;
&lt;br /&gt;
			if label ~= &amp;quot;&amp;quot; then&lt;br /&gt;
				return space .. label&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	return &amp;quot;&amp;quot;&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function State:getValue(snak)&lt;br /&gt;
	return self.conf:getValue(snak, self.rawValue, self.linked, self.shortName, self.anyLanguage, self.unitOnly, false, self.type:sub(1,2))&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function Config:getValue(snak, raw, link, short, anyLang, unitOnly, noSpecial, type)&lt;br /&gt;
	if snak.snaktype == &#039;value&#039; then&lt;br /&gt;
		local datatype = snak.datavalue.type&lt;br /&gt;
		local subtype = snak.datatype&lt;br /&gt;
		local datavalue = snak.datavalue.value&lt;br /&gt;
&lt;br /&gt;
		if datatype == &#039;string&#039; then&lt;br /&gt;
			if subtype == &#039;url&#039; and link then&lt;br /&gt;
				-- create link explicitly&lt;br /&gt;
				if raw then&lt;br /&gt;
					-- will render as a linked number like [1]&lt;br /&gt;
					return &amp;quot;[&amp;quot; .. datavalue .. &amp;quot;]&amp;quot;&lt;br /&gt;
				else&lt;br /&gt;
					return &amp;quot;[&amp;quot; .. datavalue .. &amp;quot; &amp;quot; .. datavalue .. &amp;quot;]&amp;quot;&lt;br /&gt;
				end&lt;br /&gt;
			elseif subtype == &#039;commonsMedia&#039; then&lt;br /&gt;
				if link then&lt;br /&gt;
					return buildWikilink(&amp;quot;c:File:&amp;quot; .. datavalue, datavalue)&lt;br /&gt;
				elseif not raw then&lt;br /&gt;
					return &amp;quot;[[File:&amp;quot; .. datavalue .. &amp;quot;]]&amp;quot;&lt;br /&gt;
				else&lt;br /&gt;
					return datavalue&lt;br /&gt;
				end&lt;br /&gt;
			elseif subtype == &#039;geo-shape&#039; and link then&lt;br /&gt;
				return buildWikilink(&amp;quot;c:&amp;quot; .. datavalue, datavalue)&lt;br /&gt;
			elseif subtype == &#039;math&#039; and not raw then&lt;br /&gt;
				local attribute = nil&lt;br /&gt;
&lt;br /&gt;
				if (type == parameters.property or (type == parameters.qualifier and self.propertyID == aliasesP.hasPart)) and snak.property == aliasesP.definingFormula then&lt;br /&gt;
					attribute = {qid = self.entityID}&lt;br /&gt;
				end&lt;br /&gt;
&lt;br /&gt;
				return mw.getCurrentFrame():extensionTag(&amp;quot;math&amp;quot;, datavalue, attribute)&lt;br /&gt;
			elseif subtype == &#039;external-id&#039; and link then&lt;br /&gt;
				local url = p._property{aliasesP.formatterURL, [p.args.eid] = snak.property}  -- get formatter URL&lt;br /&gt;
&lt;br /&gt;
				if url ~= &amp;quot;&amp;quot; then&lt;br /&gt;
					url = mw.ustring.gsub(url, &amp;quot;$1&amp;quot;, datavalue)&lt;br /&gt;
					return &amp;quot;[&amp;quot; .. url .. &amp;quot; &amp;quot; .. datavalue .. &amp;quot;]&amp;quot;&lt;br /&gt;
				else&lt;br /&gt;
					return datavalue&lt;br /&gt;
				end&lt;br /&gt;
			else&lt;br /&gt;
				return datavalue&lt;br /&gt;
			end&lt;br /&gt;
		elseif datatype == &#039;monolingualtext&#039; then&lt;br /&gt;
			if anyLang or datavalue[&#039;language&#039;] == self.langCode then&lt;br /&gt;
				return datavalue[&#039;text&#039;]&lt;br /&gt;
			else&lt;br /&gt;
				return nil&lt;br /&gt;
			end&lt;br /&gt;
		elseif datatype == &#039;quantity&#039; then&lt;br /&gt;
			local value = &amp;quot;&amp;quot;&lt;br /&gt;
			local unit&lt;br /&gt;
&lt;br /&gt;
			if not unitOnly then&lt;br /&gt;
				-- get value and strip + signs from front&lt;br /&gt;
				value = mw.ustring.gsub(datavalue[&#039;amount&#039;], &amp;quot;^%+(.+)$&amp;quot;, &amp;quot;%1&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
				if raw then&lt;br /&gt;
					return value&lt;br /&gt;
				end&lt;br /&gt;
&lt;br /&gt;
				-- replace decimal mark based on locale&lt;br /&gt;
				value = replaceDecimalMark(value)&lt;br /&gt;
&lt;br /&gt;
				-- add delimiters for readability&lt;br /&gt;
				value = i18n.addDelimiters(value)&lt;br /&gt;
			end&lt;br /&gt;
&lt;br /&gt;
			unit = self:convertUnit(datavalue[&#039;unit&#039;], raw, link, short, unitOnly)&lt;br /&gt;
&lt;br /&gt;
			if unit then&lt;br /&gt;
				value = value .. unit&lt;br /&gt;
			end&lt;br /&gt;
&lt;br /&gt;
			return value&lt;br /&gt;
		elseif datatype == &#039;time&#039; then&lt;br /&gt;
			local y, m, d, p, yDiv, yRound, yFull, value, calendarID, dateStr&lt;br /&gt;
			local yFactor = 1&lt;br /&gt;
			local sign = 1&lt;br /&gt;
			local prefix = &amp;quot;&amp;quot;&lt;br /&gt;
			local suffix = &amp;quot;&amp;quot;&lt;br /&gt;
			local mayAddCalendar = false&lt;br /&gt;
			local calendar = &amp;quot;&amp;quot;&lt;br /&gt;
			local precision = datavalue[&#039;precision&#039;]&lt;br /&gt;
&lt;br /&gt;
			if precision == 11 then&lt;br /&gt;
				p = &amp;quot;d&amp;quot;&lt;br /&gt;
			elseif precision == 10 then&lt;br /&gt;
				p = &amp;quot;m&amp;quot;&lt;br /&gt;
			else&lt;br /&gt;
				p = &amp;quot;y&amp;quot;&lt;br /&gt;
				yFactor = 10^(9-precision)&lt;br /&gt;
			end&lt;br /&gt;
&lt;br /&gt;
			y, m, d = parseDate(datavalue[&#039;time&#039;], p)&lt;br /&gt;
&lt;br /&gt;
			if y &amp;lt; 0 then&lt;br /&gt;
				sign = -1&lt;br /&gt;
				y = y * sign&lt;br /&gt;
			end&lt;br /&gt;
&lt;br /&gt;
			-- if precision is tens/hundreds/thousands/millions/billions of years&lt;br /&gt;
			if precision &amp;lt;= 8 then&lt;br /&gt;
				yDiv = y / yFactor&lt;br /&gt;
&lt;br /&gt;
				-- if precision is tens/hundreds/thousands of years&lt;br /&gt;
				if precision &amp;gt;= 6 then&lt;br /&gt;
					mayAddCalendar = true&lt;br /&gt;
&lt;br /&gt;
					if precision &amp;lt;= 7 then&lt;br /&gt;
						-- round centuries/millenniums up (e.g. 20th century or 3rd millennium)&lt;br /&gt;
						yRound = math.ceil(yDiv)&lt;br /&gt;
&lt;br /&gt;
						if not raw then&lt;br /&gt;
							if precision == 6 then&lt;br /&gt;
								suffix = i18n[&#039;datetime&#039;][&#039;suffixes&#039;][&#039;millennium&#039;]&lt;br /&gt;
							else&lt;br /&gt;
								suffix = i18n[&#039;datetime&#039;][&#039;suffixes&#039;][&#039;century&#039;]&lt;br /&gt;
							end&lt;br /&gt;
&lt;br /&gt;
							suffix = i18n.getOrdinalSuffix(yRound) .. suffix&lt;br /&gt;
						else&lt;br /&gt;
							-- if not verbose, take the first year of the century/millennium&lt;br /&gt;
							-- (e.g. 1901 for 20th century or 2001 for 3rd millennium)&lt;br /&gt;
							yRound = (yRound - 1) * yFactor + 1&lt;br /&gt;
						end&lt;br /&gt;
					else&lt;br /&gt;
						-- precision == 8&lt;br /&gt;
						-- round decades down (e.g. 2010s)&lt;br /&gt;
						yRound = math.floor(yDiv) * yFactor&lt;br /&gt;
&lt;br /&gt;
						if not raw then&lt;br /&gt;
							prefix = i18n[&#039;datetime&#039;][&#039;prefixes&#039;][&#039;decade-period&#039;]&lt;br /&gt;
							suffix = i18n[&#039;datetime&#039;][&#039;suffixes&#039;][&#039;decade-period&#039;]&lt;br /&gt;
						end&lt;br /&gt;
					end&lt;br /&gt;
&lt;br /&gt;
					if raw and sign &amp;lt; 0 then&lt;br /&gt;
						-- if BCE then compensate for &amp;quot;counting backwards&amp;quot;&lt;br /&gt;
						-- (e.g. -2019 for 2010s BCE, -2000 for 20th century BCE or -3000 for 3rd millennium BCE)&lt;br /&gt;
						yRound = yRound + yFactor - 1&lt;br /&gt;
					end&lt;br /&gt;
				else&lt;br /&gt;
					local yReFactor, yReDiv, yReRound&lt;br /&gt;
&lt;br /&gt;
					-- round to nearest for tens of thousands of years or more&lt;br /&gt;
					yRound = math.floor(yDiv + 0.5)&lt;br /&gt;
&lt;br /&gt;
					if yRound == 0 then&lt;br /&gt;
						if precision &amp;lt;= 2 and y ~= 0 then&lt;br /&gt;
							yReFactor = 1e6&lt;br /&gt;
							yReDiv = y / yReFactor&lt;br /&gt;
							yReRound = math.floor(yReDiv + 0.5)&lt;br /&gt;
&lt;br /&gt;
							if yReDiv == yReRound then&lt;br /&gt;
								-- change precision to millions of years only if we have a whole number of them&lt;br /&gt;
								precision = 3&lt;br /&gt;
								yFactor = yReFactor&lt;br /&gt;
								yRound = yReRound&lt;br /&gt;
							end&lt;br /&gt;
						end&lt;br /&gt;
&lt;br /&gt;
						if yRound == 0 then&lt;br /&gt;
							-- otherwise, take the unrounded (original) number of years&lt;br /&gt;
							precision = 5&lt;br /&gt;
							yFactor = 1&lt;br /&gt;
							yRound = y&lt;br /&gt;
							mayAddCalendar = true&lt;br /&gt;
						end&lt;br /&gt;
					end&lt;br /&gt;
&lt;br /&gt;
					if precision &amp;gt;= 1 and y ~= 0 then&lt;br /&gt;
						yFull = yRound * yFactor&lt;br /&gt;
&lt;br /&gt;
						yReFactor = 1e9&lt;br /&gt;
						yReDiv = yFull / yReFactor&lt;br /&gt;
						yReRound = math.floor(yReDiv + 0.5)&lt;br /&gt;
&lt;br /&gt;
						if yReDiv == yReRound then&lt;br /&gt;
							-- change precision to billions of years if we&#039;re in that range&lt;br /&gt;
							precision = 0&lt;br /&gt;
							yFactor = yReFactor&lt;br /&gt;
							yRound = yReRound&lt;br /&gt;
						else&lt;br /&gt;
							yReFactor = 1e6&lt;br /&gt;
							yReDiv = yFull / yReFactor&lt;br /&gt;
							yReRound = math.floor(yReDiv + 0.5)&lt;br /&gt;
&lt;br /&gt;
							if yReDiv == yReRound then&lt;br /&gt;
								-- change precision to millions of years if we&#039;re in that range&lt;br /&gt;
								precision = 3&lt;br /&gt;
								yFactor = yReFactor&lt;br /&gt;
								yRound = yReRound&lt;br /&gt;
							end&lt;br /&gt;
						end&lt;br /&gt;
					end&lt;br /&gt;
&lt;br /&gt;
					if not raw then&lt;br /&gt;
						if precision == 3 then&lt;br /&gt;
							suffix = i18n[&#039;datetime&#039;][&#039;suffixes&#039;][&#039;million-years&#039;]&lt;br /&gt;
						elseif precision == 0 then&lt;br /&gt;
							suffix = i18n[&#039;datetime&#039;][&#039;suffixes&#039;][&#039;billion-years&#039;]&lt;br /&gt;
						else&lt;br /&gt;
							yRound = yRound * yFactor&lt;br /&gt;
							if yRound == 1 then&lt;br /&gt;
								suffix = i18n[&#039;datetime&#039;][&#039;suffixes&#039;][&#039;year&#039;]&lt;br /&gt;
							else&lt;br /&gt;
								suffix = i18n[&#039;datetime&#039;][&#039;suffixes&#039;][&#039;years&#039;]&lt;br /&gt;
							end&lt;br /&gt;
						end&lt;br /&gt;
					else&lt;br /&gt;
						yRound = yRound * yFactor&lt;br /&gt;
					end&lt;br /&gt;
				end&lt;br /&gt;
			else&lt;br /&gt;
				yRound = y&lt;br /&gt;
				mayAddCalendar = true&lt;br /&gt;
			end&lt;br /&gt;
&lt;br /&gt;
			if mayAddCalendar then&lt;br /&gt;
				calendarID = parseWikidataURL(datavalue[&#039;calendarmodel&#039;])&lt;br /&gt;
&lt;br /&gt;
				if calendarID and calendarID == aliasesQ.prolepticJulianCalendar then&lt;br /&gt;
					if not raw then&lt;br /&gt;
						if link then&lt;br /&gt;
							calendar = &amp;quot; (&amp;quot;..buildWikilink(i18n[&#039;datetime&#039;][&#039;julian-calendar&#039;], i18n[&#039;datetime&#039;][&#039;julian&#039;])..&amp;quot;)&amp;quot;&lt;br /&gt;
						else&lt;br /&gt;
							calendar = &amp;quot; (&amp;quot;..i18n[&#039;datetime&#039;][&#039;julian&#039;]..&amp;quot;)&amp;quot;&lt;br /&gt;
						end&lt;br /&gt;
					else&lt;br /&gt;
						calendar = &amp;quot;/&amp;quot;..i18n[&#039;datetime&#039;][&#039;julian&#039;]&lt;br /&gt;
					end&lt;br /&gt;
				end&lt;br /&gt;
			end&lt;br /&gt;
&lt;br /&gt;
			if not raw then&lt;br /&gt;
				local ce = nil&lt;br /&gt;
&lt;br /&gt;
				if sign &amp;lt; 0 then&lt;br /&gt;
					ce = i18n[&#039;datetime&#039;][&#039;BCE&#039;]&lt;br /&gt;
				elseif precision &amp;lt;= 5 then&lt;br /&gt;
					ce = i18n[&#039;datetime&#039;][&#039;CE&#039;]&lt;br /&gt;
				end&lt;br /&gt;
&lt;br /&gt;
				if ce then&lt;br /&gt;
					if link then&lt;br /&gt;
						ce = buildWikilink(i18n[&#039;datetime&#039;][&#039;common-era&#039;], ce)&lt;br /&gt;
					end&lt;br /&gt;
					suffix = suffix .. &amp;quot; &amp;quot; .. ce&lt;br /&gt;
				end&lt;br /&gt;
&lt;br /&gt;
				value = tostring(yRound)&lt;br /&gt;
&lt;br /&gt;
				if m then&lt;br /&gt;
					dateStr = self.langObj:formatDate(&amp;quot;F&amp;quot;, &amp;quot;1-&amp;quot;..m..&amp;quot;-1&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
					if d then&lt;br /&gt;
						if self.mdyDate then&lt;br /&gt;
							dateStr = dateStr .. &amp;quot; &amp;quot; .. d .. &amp;quot;,&amp;quot;&lt;br /&gt;
						else&lt;br /&gt;
							dateStr = d .. &amp;quot; &amp;quot; .. dateStr&lt;br /&gt;
						end&lt;br /&gt;
					end&lt;br /&gt;
&lt;br /&gt;
					value = dateStr .. &amp;quot; &amp;quot; .. value&lt;br /&gt;
				end&lt;br /&gt;
&lt;br /&gt;
				value = prefix .. value .. suffix .. calendar&lt;br /&gt;
			else&lt;br /&gt;
				value = padZeros(yRound * sign, 4)&lt;br /&gt;
&lt;br /&gt;
				if m then&lt;br /&gt;
					value = value .. &amp;quot;-&amp;quot; .. padZeros(m, 2)&lt;br /&gt;
&lt;br /&gt;
					if d then&lt;br /&gt;
						value = value .. &amp;quot;-&amp;quot; .. padZeros(d, 2)&lt;br /&gt;
					end&lt;br /&gt;
				end&lt;br /&gt;
&lt;br /&gt;
				value = value .. calendar&lt;br /&gt;
			end&lt;br /&gt;
&lt;br /&gt;
			return value&lt;br /&gt;
		elseif datatype == &#039;globecoordinate&#039; then&lt;br /&gt;
			-- logic from https://github.com/DataValues/Geo (v4.0.1)&lt;br /&gt;
&lt;br /&gt;
			local precision, unitsPerDegree, numDigits, strFormat, value, globe&lt;br /&gt;
			local latitude, latConv, latValue, latLink&lt;br /&gt;
			local longitude, lonConv, lonValue, lonLink&lt;br /&gt;
			local latDirection, latDirectionN, latDirectionS, latDirectionEN&lt;br /&gt;
			local lonDirection, lonDirectionE, lonDirectionW, lonDirectionEN&lt;br /&gt;
			local degSymbol, minSymbol, secSymbol, separator&lt;br /&gt;
&lt;br /&gt;
			local latDegrees = nil&lt;br /&gt;
			local latMinutes = nil&lt;br /&gt;
			local latSeconds = nil&lt;br /&gt;
			local lonDegrees = nil&lt;br /&gt;
			local lonMinutes = nil&lt;br /&gt;
			local lonSeconds = nil&lt;br /&gt;
&lt;br /&gt;
			local latDegSym = &amp;quot;&amp;quot;&lt;br /&gt;
			local latMinSym = &amp;quot;&amp;quot;&lt;br /&gt;
			local latSecSym = &amp;quot;&amp;quot;&lt;br /&gt;
			local lonDegSym = &amp;quot;&amp;quot;&lt;br /&gt;
			local lonMinSym = &amp;quot;&amp;quot;&lt;br /&gt;
			local lonSecSym = &amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
			local latDirectionEN_N = &amp;quot;N&amp;quot;&lt;br /&gt;
			local latDirectionEN_S = &amp;quot;S&amp;quot;&lt;br /&gt;
			local lonDirectionEN_E = &amp;quot;E&amp;quot;&lt;br /&gt;
			local lonDirectionEN_W = &amp;quot;W&amp;quot;&lt;br /&gt;
&lt;br /&gt;
			if not raw then&lt;br /&gt;
				latDirectionN = i18n[&#039;coord&#039;][&#039;latitude-north&#039;]&lt;br /&gt;
				latDirectionS = i18n[&#039;coord&#039;][&#039;latitude-south&#039;]&lt;br /&gt;
				lonDirectionE = i18n[&#039;coord&#039;][&#039;longitude-east&#039;]&lt;br /&gt;
				lonDirectionW = i18n[&#039;coord&#039;][&#039;longitude-west&#039;]&lt;br /&gt;
&lt;br /&gt;
				degSymbol = i18n[&#039;coord&#039;][&#039;degrees&#039;]&lt;br /&gt;
				minSymbol = i18n[&#039;coord&#039;][&#039;minutes&#039;]&lt;br /&gt;
				secSymbol = i18n[&#039;coord&#039;][&#039;seconds&#039;]&lt;br /&gt;
				separator = i18n[&#039;coord&#039;][&#039;separator&#039;]&lt;br /&gt;
			else&lt;br /&gt;
				latDirectionN = latDirectionEN_N&lt;br /&gt;
				latDirectionS = latDirectionEN_S&lt;br /&gt;
				lonDirectionE = lonDirectionEN_E&lt;br /&gt;
				lonDirectionW = lonDirectionEN_W&lt;br /&gt;
&lt;br /&gt;
				degSymbol = &amp;quot;/&amp;quot;&lt;br /&gt;
				minSymbol = &amp;quot;/&amp;quot;&lt;br /&gt;
				secSymbol = &amp;quot;/&amp;quot;&lt;br /&gt;
				separator = &amp;quot;/&amp;quot;&lt;br /&gt;
			end&lt;br /&gt;
&lt;br /&gt;
			latitude = datavalue[&#039;latitude&#039;]&lt;br /&gt;
			longitude = datavalue[&#039;longitude&#039;]&lt;br /&gt;
&lt;br /&gt;
			if latitude &amp;lt; 0 then&lt;br /&gt;
				latDirection = latDirectionS&lt;br /&gt;
				latDirectionEN = latDirectionEN_S&lt;br /&gt;
				latitude = math.abs(latitude)&lt;br /&gt;
			else&lt;br /&gt;
				latDirection = latDirectionN&lt;br /&gt;
				latDirectionEN = latDirectionEN_N&lt;br /&gt;
			end&lt;br /&gt;
&lt;br /&gt;
			if longitude &amp;lt; 0 then&lt;br /&gt;
				lonDirection = lonDirectionW&lt;br /&gt;
				lonDirectionEN = lonDirectionEN_W&lt;br /&gt;
				longitude = math.abs(longitude)&lt;br /&gt;
			else&lt;br /&gt;
				lonDirection = lonDirectionE&lt;br /&gt;
				lonDirectionEN = lonDirectionEN_E&lt;br /&gt;
			end&lt;br /&gt;
&lt;br /&gt;
			precision = datavalue[&#039;precision&#039;]&lt;br /&gt;
&lt;br /&gt;
			if not precision or precision &amp;lt;= 0 then&lt;br /&gt;
				precision = 1 / 3600  -- precision not set (correctly), set to arcsecond&lt;br /&gt;
			end&lt;br /&gt;
&lt;br /&gt;
			-- remove insignificant detail&lt;br /&gt;
			latitude = math.floor(latitude / precision + 0.5) * precision&lt;br /&gt;
			longitude = math.floor(longitude / precision + 0.5) * precision&lt;br /&gt;
&lt;br /&gt;
			if precision &amp;gt;= 1 - (1 / 60) and precision &amp;lt; 1 then&lt;br /&gt;
				precision = 1&lt;br /&gt;
			elseif precision &amp;gt;= (1 / 60) - (1 / 3600) and precision &amp;lt; (1 / 60) then&lt;br /&gt;
				precision = 1 / 60&lt;br /&gt;
			end&lt;br /&gt;
&lt;br /&gt;
			if precision &amp;gt;= 1 then&lt;br /&gt;
				unitsPerDegree = 1&lt;br /&gt;
			elseif precision &amp;gt;= (1 / 60)  then&lt;br /&gt;
				unitsPerDegree = 60&lt;br /&gt;
			else&lt;br /&gt;
				unitsPerDegree = 3600&lt;br /&gt;
			end&lt;br /&gt;
&lt;br /&gt;
			numDigits = math.ceil(-math.log10(unitsPerDegree * precision))&lt;br /&gt;
&lt;br /&gt;
			if numDigits &amp;lt;= 0 then&lt;br /&gt;
				numDigits = tonumber(&amp;quot;0&amp;quot;)  -- for some reason, &#039;numDigits = 0&#039; may actually store &#039;-0&#039;, so parse from string instead&lt;br /&gt;
			end&lt;br /&gt;
&lt;br /&gt;
			strFormat = &amp;quot;%.&amp;quot; .. numDigits .. &amp;quot;f&amp;quot;&lt;br /&gt;
&lt;br /&gt;
			if precision &amp;gt;= 1 then&lt;br /&gt;
				latDegrees = strFormat:format(latitude)&lt;br /&gt;
				lonDegrees = strFormat:format(longitude)&lt;br /&gt;
&lt;br /&gt;
				if not raw then&lt;br /&gt;
					latDegSym = replaceDecimalMark(latDegrees) .. degSymbol&lt;br /&gt;
					lonDegSym = replaceDecimalMark(lonDegrees) .. degSymbol&lt;br /&gt;
				else&lt;br /&gt;
					latDegSym = latDegrees .. degSymbol&lt;br /&gt;
					lonDegSym = lonDegrees .. degSymbol&lt;br /&gt;
				end&lt;br /&gt;
			else&lt;br /&gt;
				latConv = math.floor(latitude * unitsPerDegree * 10^numDigits + 0.5) / 10^numDigits&lt;br /&gt;
				lonConv = math.floor(longitude * unitsPerDegree * 10^numDigits + 0.5) / 10^numDigits&lt;br /&gt;
&lt;br /&gt;
				if precision &amp;gt;= (1 / 60) then&lt;br /&gt;
					latMinutes = latConv&lt;br /&gt;
					lonMinutes = lonConv&lt;br /&gt;
				else&lt;br /&gt;
					latSeconds = latConv&lt;br /&gt;
					lonSeconds = lonConv&lt;br /&gt;
&lt;br /&gt;
					latMinutes = math.floor(latSeconds / 60)&lt;br /&gt;
					lonMinutes = math.floor(lonSeconds / 60)&lt;br /&gt;
&lt;br /&gt;
					latSeconds = strFormat:format(latSeconds - (latMinutes * 60))&lt;br /&gt;
					lonSeconds = strFormat:format(lonSeconds - (lonMinutes * 60))&lt;br /&gt;
&lt;br /&gt;
					if not raw then&lt;br /&gt;
						latSecSym = replaceDecimalMark(latSeconds) .. secSymbol&lt;br /&gt;
						lonSecSym = replaceDecimalMark(lonSeconds) .. secSymbol&lt;br /&gt;
					else&lt;br /&gt;
						latSecSym = latSeconds .. secSymbol&lt;br /&gt;
						lonSecSym = lonSeconds .. secSymbol&lt;br /&gt;
					end&lt;br /&gt;
				end&lt;br /&gt;
&lt;br /&gt;
				latDegrees = math.floor(latMinutes / 60)&lt;br /&gt;
				lonDegrees = math.floor(lonMinutes / 60)&lt;br /&gt;
&lt;br /&gt;
				latDegSym = latDegrees .. degSymbol&lt;br /&gt;
				lonDegSym = lonDegrees .. degSymbol&lt;br /&gt;
&lt;br /&gt;
				latMinutes = latMinutes - (latDegrees * 60)&lt;br /&gt;
				lonMinutes = lonMinutes - (lonDegrees * 60)&lt;br /&gt;
&lt;br /&gt;
				if precision &amp;gt;= (1 / 60) then&lt;br /&gt;
					latMinutes = strFormat:format(latMinutes)&lt;br /&gt;
					lonMinutes = strFormat:format(lonMinutes)&lt;br /&gt;
&lt;br /&gt;
					if not raw then&lt;br /&gt;
						latMinSym = replaceDecimalMark(latMinutes) .. minSymbol&lt;br /&gt;
						lonMinSym = replaceDecimalMark(lonMinutes) .. minSymbol&lt;br /&gt;
					else&lt;br /&gt;
						latMinSym = latMinutes .. minSymbol&lt;br /&gt;
						lonMinSym = lonMinutes .. minSymbol&lt;br /&gt;
					end&lt;br /&gt;
				else&lt;br /&gt;
					latMinSym = latMinutes .. minSymbol&lt;br /&gt;
					lonMinSym = lonMinutes .. minSymbol&lt;br /&gt;
				end&lt;br /&gt;
			end&lt;br /&gt;
&lt;br /&gt;
			latValue = latDegSym .. latMinSym .. latSecSym .. latDirection&lt;br /&gt;
			lonValue = lonDegSym .. lonMinSym .. lonSecSym .. lonDirection&lt;br /&gt;
&lt;br /&gt;
			value = latValue .. separator .. lonValue&lt;br /&gt;
&lt;br /&gt;
			if link then&lt;br /&gt;
				globe = parseWikidataURL(datavalue[&#039;globe&#039;])&lt;br /&gt;
&lt;br /&gt;
				if globe then&lt;br /&gt;
					globe = mw.wikibase.getLabelByLang(globe, &amp;quot;en&amp;quot;):lower()&lt;br /&gt;
				else&lt;br /&gt;
					globe = &amp;quot;earth&amp;quot;&lt;br /&gt;
				end&lt;br /&gt;
&lt;br /&gt;
				latLink = table.concat({latDegrees, latMinutes, latSeconds}, &amp;quot;_&amp;quot;)&lt;br /&gt;
				lonLink = table.concat({lonDegrees, lonMinutes, lonSeconds}, &amp;quot;_&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
				value = &amp;quot;[https://geohack.toolforge.org/geohack.php?language=&amp;quot;..self.langCode..&amp;quot;&amp;amp;params=&amp;quot;..latLink..&amp;quot;_&amp;quot;..latDirectionEN..&amp;quot;_&amp;quot;..lonLink..&amp;quot;_&amp;quot;..lonDirectionEN..&amp;quot;_globe:&amp;quot;..globe..&amp;quot; &amp;quot;..value..&amp;quot;]&amp;quot;&lt;br /&gt;
			end&lt;br /&gt;
&lt;br /&gt;
			return value&lt;br /&gt;
		elseif datatype == &#039;wikibase-entityid&#039; then&lt;br /&gt;
			local label&lt;br /&gt;
			local itemID = datavalue[&#039;numeric-id&#039;]&lt;br /&gt;
&lt;br /&gt;
			if subtype == &#039;wikibase-item&#039; then&lt;br /&gt;
				itemID = &amp;quot;Q&amp;quot; .. itemID&lt;br /&gt;
			elseif subtype == &#039;wikibase-property&#039; then&lt;br /&gt;
				itemID = &amp;quot;P&amp;quot; .. itemID&lt;br /&gt;
			else&lt;br /&gt;
				return &#039;&amp;lt;strong class=&amp;quot;error&amp;quot;&amp;gt;&#039; .. errorText(&#039;unknown-data-type&#039;, subtype) .. &#039;&amp;lt;/strong&amp;gt;&#039;&lt;br /&gt;
			end&lt;br /&gt;
&lt;br /&gt;
			label = self:getLabel(itemID, raw, link, short)&lt;br /&gt;
&lt;br /&gt;
			if label == &amp;quot;&amp;quot; then&lt;br /&gt;
				label = nil&lt;br /&gt;
			end&lt;br /&gt;
&lt;br /&gt;
			return label&lt;br /&gt;
		else&lt;br /&gt;
			return &#039;&amp;lt;strong class=&amp;quot;error&amp;quot;&amp;gt;&#039; .. errorText(&#039;unknown-data-type&#039;, datatype) .. &#039;&amp;lt;/strong&amp;gt;&#039;&lt;br /&gt;
		end&lt;br /&gt;
	elseif snak.snaktype == &#039;somevalue&#039; and not noSpecial then&lt;br /&gt;
		if raw then&lt;br /&gt;
			return &amp;quot; &amp;quot;  -- single space represents &#039;somevalue&#039;&lt;br /&gt;
		else&lt;br /&gt;
			return i18n[&#039;values&#039;][&#039;unknown&#039;]&lt;br /&gt;
		end&lt;br /&gt;
	elseif snak.snaktype == &#039;novalue&#039; and not noSpecial then&lt;br /&gt;
		if raw then&lt;br /&gt;
			return &amp;quot;&amp;quot;  -- empty string represents &#039;novalue&#039;&lt;br /&gt;
		else&lt;br /&gt;
			return i18n[&#039;values&#039;][&#039;none&#039;]&lt;br /&gt;
		end&lt;br /&gt;
	else&lt;br /&gt;
		return nil&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function Config:getSingleRawQualifier(claim, qualifierID)&lt;br /&gt;
	local qualifiers&lt;br /&gt;
&lt;br /&gt;
	if claim.qualifiers then qualifiers = claim.qualifiers[qualifierID] end&lt;br /&gt;
&lt;br /&gt;
	if qualifiers and qualifiers[1] then&lt;br /&gt;
		return self:getValue(qualifiers[1], true)  -- raw = true&lt;br /&gt;
	else&lt;br /&gt;
		return nil&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function Config:snakEqualsValue(snak, value)&lt;br /&gt;
	local snakValue = self:getValue(snak, true)  -- raw = true&lt;br /&gt;
&lt;br /&gt;
	if snakValue and snak.snaktype == &#039;value&#039; and snak.datavalue.type == &#039;wikibase-entityid&#039; then value = value:upper() end&lt;br /&gt;
&lt;br /&gt;
	return snakValue == value&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function Config:setRank(rank)&lt;br /&gt;
	local rankPos&lt;br /&gt;
&lt;br /&gt;
	if rank == p.flags.best then&lt;br /&gt;
		self.bestRank = true&lt;br /&gt;
		self.flagBest = true  -- mark that &#039;best&#039; flag was given&lt;br /&gt;
		return&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	if rank:sub(1,9) == p.flags.preferred then&lt;br /&gt;
		rankPos = 1&lt;br /&gt;
	elseif rank:sub(1,6) == p.flags.normal then&lt;br /&gt;
		rankPos = 2&lt;br /&gt;
	elseif rank:sub(1,10) == p.flags.deprecated then&lt;br /&gt;
		rankPos = 3&lt;br /&gt;
	else&lt;br /&gt;
		return&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- one of the rank flags was given, check if another one was given before&lt;br /&gt;
	if not self.flagRank then&lt;br /&gt;
		self.ranks = {false, false, false}  -- no other rank flag given before, so unset ranks&lt;br /&gt;
		self.bestRank = self.flagBest       -- unsets bestRank only if &#039;best&#039; flag was not given before&lt;br /&gt;
		self.flagRank = true                -- mark that a rank flag was given&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	if rank:sub(-1) == &amp;quot;+&amp;quot; then&lt;br /&gt;
		for i = rankPos, 1, -1 do&lt;br /&gt;
			self.ranks[i] = true&lt;br /&gt;
		end&lt;br /&gt;
	elseif rank:sub(-1) == &amp;quot;-&amp;quot; then&lt;br /&gt;
		for i = rankPos, #self.ranks do&lt;br /&gt;
			self.ranks[i] = true&lt;br /&gt;
		end&lt;br /&gt;
	else&lt;br /&gt;
		self.ranks[rankPos] = true&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function Config:setPeriod(period)&lt;br /&gt;
	local periodPos&lt;br /&gt;
&lt;br /&gt;
	if period == p.flags.future then&lt;br /&gt;
		periodPos = 1&lt;br /&gt;
	elseif period == p.flags.current then&lt;br /&gt;
		periodPos = 2&lt;br /&gt;
	elseif period == p.flags.former then&lt;br /&gt;
		periodPos = 3&lt;br /&gt;
	else&lt;br /&gt;
		return&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- one of the period flags was given, check if another one was given before&lt;br /&gt;
	if not self.flagPeriod then&lt;br /&gt;
		self.periods = {false, false, false}  -- no other period flag given before, so unset periods&lt;br /&gt;
		self.flagPeriod = true                -- mark that a period flag was given&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	self.periods[periodPos] = true&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function Config:qualifierMatches(claim, id, value)&lt;br /&gt;
	local qualifiers&lt;br /&gt;
&lt;br /&gt;
	if claim.qualifiers then qualifiers = claim.qualifiers[id] end&lt;br /&gt;
	if qualifiers then&lt;br /&gt;
		for _, v in pairs(qualifiers) do&lt;br /&gt;
			if self:snakEqualsValue(v, value) then&lt;br /&gt;
				return true&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
	elseif value == &amp;quot;&amp;quot; then&lt;br /&gt;
		-- if the qualifier is not present then treat it the same as the special value &#039;novalue&#039;&lt;br /&gt;
		return true&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	return false&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function Config:rankMatches(rankPos)&lt;br /&gt;
	if self.bestRank then&lt;br /&gt;
		return (self.ranks[rankPos] and self.foundRank &amp;gt;= rankPos)&lt;br /&gt;
	else&lt;br /&gt;
		return self.ranks[rankPos]&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function Config:timeMatches(claim)&lt;br /&gt;
	local startTime = nil&lt;br /&gt;
	local startTimeY = nil&lt;br /&gt;
	local startTimeM = nil&lt;br /&gt;
	local startTimeD = nil&lt;br /&gt;
	local endTime = nil&lt;br /&gt;
	local endTimeY = nil&lt;br /&gt;
	local endTimeM = nil&lt;br /&gt;
	local endTimeD = nil&lt;br /&gt;
&lt;br /&gt;
	if self.periods[1] and self.periods[2] and self.periods[3] then&lt;br /&gt;
		-- any time&lt;br /&gt;
		return true&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	startTime = self:getSingleRawQualifier(claim, aliasesP.startTime)&lt;br /&gt;
	if startTime and startTime ~= &amp;quot;&amp;quot; and startTime ~= &amp;quot; &amp;quot; then&lt;br /&gt;
		startTimeY, startTimeM, startTimeD = parseDate(startTime)&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	endTime = self:getSingleRawQualifier(claim, aliasesP.endTime)&lt;br /&gt;
	if endTime and endTime ~= &amp;quot;&amp;quot; and endTime ~= &amp;quot; &amp;quot; then&lt;br /&gt;
		endTimeY, endTimeM, endTimeD = parseDate(endTime)&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	if startTimeY ~= nil and endTimeY ~= nil and datePrecedesDate(endTimeY, endTimeM, endTimeD, startTimeY, startTimeM, startTimeD) then&lt;br /&gt;
		-- invalidate end time if it precedes start time&lt;br /&gt;
		endTimeY = nil&lt;br /&gt;
		endTimeM = nil&lt;br /&gt;
		endTimeD = nil&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	if self.periods[1] then&lt;br /&gt;
		-- future&lt;br /&gt;
		if startTimeY and datePrecedesDate(self.atDate[1], self.atDate[2], self.atDate[3], startTimeY, startTimeM, startTimeD) then&lt;br /&gt;
			return true&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	if self.periods[2] then&lt;br /&gt;
		-- current&lt;br /&gt;
		if (startTimeY == nil or not datePrecedesDate(self.atDate[1], self.atDate[2], self.atDate[3], startTimeY, startTimeM, startTimeD)) and&lt;br /&gt;
		   (endTimeY == nil or datePrecedesDate(self.atDate[1], self.atDate[2], self.atDate[3], endTimeY, endTimeM, endTimeD)) then&lt;br /&gt;
			return true&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	if self.periods[3] then&lt;br /&gt;
		-- former&lt;br /&gt;
		if endTimeY and not datePrecedesDate(self.atDate[1], self.atDate[2], self.atDate[3], endTimeY, endTimeM, endTimeD) then&lt;br /&gt;
			return true&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	return false&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function Config:processFlag(flag)&lt;br /&gt;
	if not flag then&lt;br /&gt;
		return false&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	if flag == p.flags.linked then&lt;br /&gt;
		self.curState.linked = true&lt;br /&gt;
		return true&lt;br /&gt;
	elseif flag == p.flags.raw then&lt;br /&gt;
		self.curState.rawValue = true&lt;br /&gt;
&lt;br /&gt;
		if self.curState == self.states[parameters.reference] then&lt;br /&gt;
			-- raw reference values end with periods and require a separator (other than none)&lt;br /&gt;
			self.separators[&amp;quot;sep%r&amp;quot;][1] = {&amp;quot; &amp;quot;}&lt;br /&gt;
		end&lt;br /&gt;
&lt;br /&gt;
		return true&lt;br /&gt;
	elseif flag == p.flags.short then&lt;br /&gt;
		self.curState.shortName = true&lt;br /&gt;
		return true&lt;br /&gt;
	elseif flag == p.flags.multilanguage then&lt;br /&gt;
		self.curState.anyLanguage = true&lt;br /&gt;
		return true&lt;br /&gt;
	elseif flag == p.flags.unit then&lt;br /&gt;
		self.curState.unitOnly = true&lt;br /&gt;
		return true&lt;br /&gt;
	elseif flag == p.flags.mdy then&lt;br /&gt;
		self.mdyDate = true&lt;br /&gt;
		return true&lt;br /&gt;
	elseif flag == p.flags.single then&lt;br /&gt;
		self.singleClaim = true&lt;br /&gt;
		return true&lt;br /&gt;
	elseif flag == p.flags.sourced then&lt;br /&gt;
		self.sourcedOnly = true&lt;br /&gt;
		return true&lt;br /&gt;
	elseif flag == p.flags.edit then&lt;br /&gt;
		self.editable = true&lt;br /&gt;
		return true&lt;br /&gt;
	elseif flag == p.flags.editAtEnd then&lt;br /&gt;
		self.editable = true&lt;br /&gt;
		self.editAtEnd = true&lt;br /&gt;
		return true&lt;br /&gt;
	elseif flag == p.flags.best or flag:match(&#039;^&#039;..p.flags.preferred..&#039;[+-]?$&#039;) or flag:match(&#039;^&#039;..p.flags.normal..&#039;[+-]?$&#039;) or flag:match(&#039;^&#039;..p.flags.deprecated..&#039;[+-]?$&#039;) then&lt;br /&gt;
		self:setRank(flag)&lt;br /&gt;
		return true&lt;br /&gt;
	elseif flag == p.flags.future or flag == p.flags.current or flag == p.flags.former then&lt;br /&gt;
		self:setPeriod(flag)&lt;br /&gt;
		return true&lt;br /&gt;
	elseif flag == &amp;quot;&amp;quot; then&lt;br /&gt;
		-- ignore empty flags and carry on&lt;br /&gt;
		return true&lt;br /&gt;
	else&lt;br /&gt;
		return false&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function Config:processFlagOrCommand(flag)&lt;br /&gt;
	local param = &amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
	if not flag then&lt;br /&gt;
		return false&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	if flag == p.claimCommands.property or flag == p.claimCommands.properties then&lt;br /&gt;
		param = parameters.property&lt;br /&gt;
	elseif flag == p.claimCommands.qualifier or flag == p.claimCommands.qualifiers then&lt;br /&gt;
		self.states.qualifiersCount = self.states.qualifiersCount + 1&lt;br /&gt;
		param = parameters.qualifier .. self.states.qualifiersCount&lt;br /&gt;
		self.separators[&amp;quot;sep&amp;quot;..param] = {copyTable(defaultSeparators[&amp;quot;sep%q\\d&amp;quot;])}&lt;br /&gt;
	elseif flag == p.claimCommands.reference or flag == p.claimCommands.references then&lt;br /&gt;
		param = parameters.reference&lt;br /&gt;
	else&lt;br /&gt;
		return self:processFlag(flag)&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	if self.states[param] then&lt;br /&gt;
		return false&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- create a new state for each command&lt;br /&gt;
	self.states[param] = State:new(self, param)&lt;br /&gt;
&lt;br /&gt;
	-- use &amp;quot;%x&amp;quot; as the general parameter name&lt;br /&gt;
	self.states[param].parsedFormat = parseFormat(parameters.general)  -- will be overwritten for param==&amp;quot;%p&amp;quot;&lt;br /&gt;
&lt;br /&gt;
	-- set the separator&lt;br /&gt;
	self.states[param].separator = self.separators[&amp;quot;sep&amp;quot;..param]  -- will be nil for param==&amp;quot;%p&amp;quot;, which will be set separately&lt;br /&gt;
&lt;br /&gt;
	if flag == p.claimCommands.property or flag == p.claimCommands.qualifier or flag == p.claimCommands.reference then&lt;br /&gt;
		self.states[param].singleValue = true&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	self.curState = self.states[param]&lt;br /&gt;
&lt;br /&gt;
	return true&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function Config:processSeparators(args)&lt;br /&gt;
	local sep&lt;br /&gt;
&lt;br /&gt;
	for i, v in pairs(self.separators) do&lt;br /&gt;
		if args[i] then&lt;br /&gt;
			sep = replaceSpecialChars(args[i])&lt;br /&gt;
&lt;br /&gt;
			if sep ~= &amp;quot;&amp;quot; then&lt;br /&gt;
				self.separators[i][1] = {sep}&lt;br /&gt;
			else&lt;br /&gt;
				self.separators[i][1] = nil&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function Config:setFormatAndSeparators(state, parsedFormat)&lt;br /&gt;
	state.parsedFormat = parsedFormat&lt;br /&gt;
	state.separator = self.separators[&amp;quot;sep&amp;quot;]&lt;br /&gt;
	state.movSeparator = self.separators[&amp;quot;sep&amp;quot;..parameters.separator]&lt;br /&gt;
	state.puncMark = self.separators[&amp;quot;punc&amp;quot;]&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- determines if a claim has references by prefetching them from the claim using getReferences,&lt;br /&gt;
-- which applies some filtering that determines if a reference is actually returned,&lt;br /&gt;
-- and caches the references for later use&lt;br /&gt;
function State:isSourced(claim)&lt;br /&gt;
	self.conf.prefetchedRefs = self:getReferences(claim)&lt;br /&gt;
	return (#self.conf.prefetchedRefs &amp;gt; 0)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function State:resetCaches()&lt;br /&gt;
	-- any prefetched references of the previous claim must not be used&lt;br /&gt;
	self.conf.prefetchedRefs = nil&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function State:claimMatches(claim)&lt;br /&gt;
	local matches, rankPos&lt;br /&gt;
&lt;br /&gt;
	-- first of all, reset any cached values used for the previous claim&lt;br /&gt;
	self:resetCaches()&lt;br /&gt;
&lt;br /&gt;
	-- if a property value was given, check if it matches the claim&#039;s property value&lt;br /&gt;
	if self.conf.propertyValue then&lt;br /&gt;
		matches = self.conf:snakEqualsValue(claim.mainsnak, self.conf.propertyValue)&lt;br /&gt;
	else&lt;br /&gt;
		matches = true&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- if any qualifier values were given, check if each matches one of the claim&#039;s qualifier values&lt;br /&gt;
	for i, v in pairs(self.conf.qualifierIDsAndValues) do&lt;br /&gt;
		matches = (matches and self.conf:qualifierMatches(claim, i, v))&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- check if the claim&#039;s rank and time period match&lt;br /&gt;
	rankPos = rankTable[claim.rank] or 4&lt;br /&gt;
	matches = (matches and self.conf:rankMatches(rankPos) and self.conf:timeMatches(claim))&lt;br /&gt;
&lt;br /&gt;
	-- if only claims with references must be returned, check if this one has any&lt;br /&gt;
	if self.conf.sourcedOnly then&lt;br /&gt;
		matches = (matches and self:isSourced(claim))  -- prefetches and caches references&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	return matches, rankPos&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function State:out()&lt;br /&gt;
	local result  -- collection of arrays with value objects&lt;br /&gt;
	local valuesArray  -- array with value objects&lt;br /&gt;
	local sep = nil  -- value object&lt;br /&gt;
	local out = {}  -- array with value objects&lt;br /&gt;
&lt;br /&gt;
	local function walk(formatTable, result)&lt;br /&gt;
		local valuesArray = {}  -- array with value objects&lt;br /&gt;
&lt;br /&gt;
		for i, v in pairs(formatTable.req) do&lt;br /&gt;
			if not result[i] or not result[i][1] then&lt;br /&gt;
				-- we&#039;ve got no result for a parameter that is required on this level,&lt;br /&gt;
				-- so skip this level (and its children) by returning an empty result&lt;br /&gt;
				return {}&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
&lt;br /&gt;
		for _, v in ipairs(formatTable) do&lt;br /&gt;
			if v.param then&lt;br /&gt;
				valuesArray = mergeArrays(valuesArray, result[v.str])&lt;br /&gt;
			elseif v.str ~= &amp;quot;&amp;quot; then&lt;br /&gt;
				valuesArray[#valuesArray + 1] = {v.str}&lt;br /&gt;
			end&lt;br /&gt;
&lt;br /&gt;
			if v.child then&lt;br /&gt;
				valuesArray = mergeArrays(valuesArray, walk(v.child, result))&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
&lt;br /&gt;
		return valuesArray&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- iterate through the results from back to front, so that we know when to add separators&lt;br /&gt;
	for i = #self.results, 1, -1 do&lt;br /&gt;
		result = self.results[i]&lt;br /&gt;
&lt;br /&gt;
		-- if there is already some output, then add the separators&lt;br /&gt;
		if #out &amp;gt; 0 then&lt;br /&gt;
			sep = self.separator[1]  -- fixed separator&lt;br /&gt;
			result[parameters.separator] = {self.movSeparator[1]}  -- movable separator&lt;br /&gt;
		else&lt;br /&gt;
			sep = nil&lt;br /&gt;
			result[parameters.separator] = {self.puncMark[1]}  -- optional punctuation mark&lt;br /&gt;
		end&lt;br /&gt;
&lt;br /&gt;
		valuesArray = walk(self.parsedFormat, result)&lt;br /&gt;
&lt;br /&gt;
		if #valuesArray &amp;gt; 0 then&lt;br /&gt;
			if sep then&lt;br /&gt;
				valuesArray[#valuesArray + 1] = sep&lt;br /&gt;
			end&lt;br /&gt;
&lt;br /&gt;
			out = mergeArrays(valuesArray, out)&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- reset state before next iteration&lt;br /&gt;
	self.results = {}&lt;br /&gt;
&lt;br /&gt;
	return out&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- level 1 hook&lt;br /&gt;
function State:getProperty(claim)&lt;br /&gt;
	local value = {self:getValue(claim.mainsnak)}  -- create one value object&lt;br /&gt;
&lt;br /&gt;
	if #value &amp;gt; 0 then&lt;br /&gt;
		return {value}  -- wrap the value object in an array and return it&lt;br /&gt;
	else&lt;br /&gt;
		return {}  -- return empty array if there was no value&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- level 1 hook&lt;br /&gt;
function State:getQualifiers(claim, param)&lt;br /&gt;
	local qualifiers&lt;br /&gt;
&lt;br /&gt;
	if claim.qualifiers then qualifiers = claim.qualifiers[self.conf.qualifierIDs[param]] end&lt;br /&gt;
	if qualifiers then&lt;br /&gt;
		-- iterate through claim&#039;s qualifier statements to collect their values;&lt;br /&gt;
		-- return array with multiple value objects&lt;br /&gt;
		return self.conf.states[param]:iterate(qualifiers, {[parameters.general] = hookNames[parameters.qualifier..&amp;quot;\\d&amp;quot;][2], count = 1})  -- pass qualifier state with level 2 hook&lt;br /&gt;
	else&lt;br /&gt;
		return {}  -- return empty array&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- level 2 hook&lt;br /&gt;
function State:getQualifier(snak)&lt;br /&gt;
	local value = {self:getValue(snak)}  -- create one value object&lt;br /&gt;
&lt;br /&gt;
	if #value &amp;gt; 0 then&lt;br /&gt;
		return {value}  -- wrap the value object in an array and return it&lt;br /&gt;
	else&lt;br /&gt;
		return {}  -- return empty array if there was no value&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- level 1 hook&lt;br /&gt;
function State:getAllQualifiers(claim, param, result, hooks)&lt;br /&gt;
	local out = {}  -- array with value objects&lt;br /&gt;
	local sep = self.conf.separators[&amp;quot;sep&amp;quot;..parameters.qualifier][1]  -- value object&lt;br /&gt;
&lt;br /&gt;
	-- iterate through the output of the separate &amp;quot;qualifier(s)&amp;quot; commands&lt;br /&gt;
	for i = 1, self.conf.states.qualifiersCount do&lt;br /&gt;
&lt;br /&gt;
		-- if a hook has not been called yet, call it now&lt;br /&gt;
		if not result[parameters.qualifier..i] then&lt;br /&gt;
			self:callHook(parameters.qualifier..i, hooks, claim, result)&lt;br /&gt;
		end&lt;br /&gt;
&lt;br /&gt;
		-- if there is output for this particular &amp;quot;qualifier(s)&amp;quot; command, then add it&lt;br /&gt;
		if result[parameters.qualifier..i] and result[parameters.qualifier..i][1] then&lt;br /&gt;
&lt;br /&gt;
			-- if there is already some output, then add the separator&lt;br /&gt;
			if #out &amp;gt; 0 and sep then&lt;br /&gt;
				out[#out + 1] = sep&lt;br /&gt;
			end&lt;br /&gt;
&lt;br /&gt;
			out = mergeArrays(out, result[parameters.qualifier..i])&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	return out&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- level 1 hook&lt;br /&gt;
function State:getReferences(claim)&lt;br /&gt;
	if self.conf.prefetchedRefs then&lt;br /&gt;
		-- return references that have been prefetched by isSourced&lt;br /&gt;
		return self.conf.prefetchedRefs&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	if claim.references then&lt;br /&gt;
		-- iterate through claim&#039;s reference statements to collect their values;&lt;br /&gt;
		-- return array with multiple value objects&lt;br /&gt;
		return self.conf.states[parameters.reference]:iterate(claim.references, {[parameters.general] = hookNames[parameters.reference][2], count = 1})  -- pass reference state with level 2 hook&lt;br /&gt;
	else&lt;br /&gt;
		return {}  -- return empty array&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- level 2 hook&lt;br /&gt;
function State:getReference(statement)&lt;br /&gt;
	local citeParamMapping = i18n[&#039;cite&#039;][&#039;param-mapping&#039;]&lt;br /&gt;
	local citeConfig = i18n[&#039;cite&#039;][&#039;config&#039;]&lt;br /&gt;
	local citeTypes = i18n[&#039;cite&#039;][&#039;output-types&#039;]&lt;br /&gt;
	&lt;br /&gt;
	-- will hold rendered properties of the reference which are not directly from statement.snaks, &lt;br /&gt;
	-- Namely, these are a backup title from &amp;quot;subject named as&amp;quot; and a URL generated from an external ID.&lt;br /&gt;
    local additionalProcessedProperties = {}&lt;br /&gt;
    -- for each citation type, there will be an associative array that associates lists of rendered properties&lt;br /&gt;
    -- to citation-template parameters&lt;br /&gt;
    local groupedProcessedProperties = {}&lt;br /&gt;
    -- like above, but only associates one rendered property to each parameter; if the above variable&lt;br /&gt;
    -- contains more strings for a parameter, the strings will be assigned to numbered params (e.g. &amp;quot;author1&amp;quot;)&lt;br /&gt;
	local citeParams = {}&lt;br /&gt;
&lt;br /&gt;
	local citeErrors = {}&lt;br /&gt;
	local referenceEmpty = true  -- will be set to false if at least one parameter is left unremoved&lt;br /&gt;
&lt;br /&gt;
	local version = 11  -- increment this each time the below logic is changed to avoid conflict errors&lt;br /&gt;
&lt;br /&gt;
	if not statement.snaks then&lt;br /&gt;
		return {}&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- don&#039;t use bot-added references referencing Wikimedia projects or containing &amp;quot;inferred from&amp;quot; (such references are not usable on Wikipedia)&lt;br /&gt;
	if statement.snaks[aliasesP.importedFrom] or statement.snaks[aliasesP.wikimediaImportURL] or statement.snaks[aliasesP.inferredFrom] then&lt;br /&gt;
		return {}&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	-- don&#039;t include &amp;quot;type of reference&amp;quot;&lt;br /&gt;
	if statement.snaks[aliasesP.typeOfReference] then&lt;br /&gt;
		statement.snaks[aliasesP.typeOfReference] = nil&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- don&#039;t include &amp;quot;image&amp;quot; to prevent littering&lt;br /&gt;
	if statement.snaks[aliasesP.image] then&lt;br /&gt;
		statement.snaks[aliasesP.image] = nil&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- don&#039;t include &amp;quot;language&amp;quot; if it is equal to the local one&lt;br /&gt;
	if self:getReferenceDetail(statement.snaks, aliasesP.language) == self.conf.langName then&lt;br /&gt;
		statement.snaks[aliasesP.language] = nil&lt;br /&gt;
	end&lt;br /&gt;
    &lt;br /&gt;
    if statement.snaks[aliasesP.statedIn] and not statement.snaks[aliasesP.referenceURL] then&lt;br /&gt;
    	-- &amp;quot;stated in&amp;quot; was given but &amp;quot;reference URL&amp;quot; was not.&lt;br /&gt;
    	-- get &amp;quot;Wikidata property&amp;quot; properties from the item in &amp;quot;stated in&amp;quot;&lt;br /&gt;
    	-- if any of the returned properties of the external-id datatype is in statement.snaks, generate a link from it and use the link in the reference&lt;br /&gt;
    	&lt;br /&gt;
    	-- find the &amp;quot;Wikidata property&amp;quot; properties in the item from &amp;quot;stated in&amp;quot;&lt;br /&gt;
    	local wikidataPropertiesOfSource = mw.text.split(p._properties{p.flags.raw, aliasesP.wikidataProperty, [p.args.eid] = self.conf:getValue(statement.snaks[aliasesP.statedIn][1], true, false)}, &amp;quot;, &amp;quot;, true)&lt;br /&gt;
    	for i, wikidataPropertyOfSource in pairs(wikidataPropertiesOfSource) do&lt;br /&gt;
    		if statement.snaks[wikidataPropertyOfSource] and statement.snaks[wikidataPropertyOfSource][1].datatype == &amp;quot;external-id&amp;quot; then&lt;br /&gt;
    			local tempLink = self:getReferenceDetail(statement.snaks, wikidataPropertyOfSource, false, true)  -- not raw, linked&lt;br /&gt;
    			if mw.ustring.match(tempLink, &amp;quot;^%[%Z- %Z+%]$&amp;quot;) then  -- getValue returned a URL in square brackets.&lt;br /&gt;
    				-- the link is in wiki markup, so strip the square brackets and the display text&lt;br /&gt;
    				-- gsub also returns another, discarted value, therefore the result is assigned to tempLink first&lt;br /&gt;
    				tempLink = mw.ustring.gsub(tempLink, &amp;quot;^%[(%Z-) %Z+%]$&amp;quot;, &amp;quot;%1&amp;quot;)&lt;br /&gt;
    		    	additionalProcessedProperties[aliasesP.referenceURL] = {tempLink}&lt;br /&gt;
    			    statement.snaks[wikidataPropertyOfSource] = nil&lt;br /&gt;
    			    break&lt;br /&gt;
    			end&lt;br /&gt;
    		end&lt;br /&gt;
    	end&lt;br /&gt;
    end&lt;br /&gt;
    &lt;br /&gt;
    -- don&#039;t include &amp;quot;subject named as&amp;quot;, but use it as the title when &amp;quot;title&amp;quot; is not present but a URL is&lt;br /&gt;
    if statement.snaks[aliasesP.subjectNamedAs] then&lt;br /&gt;
    	if not statement.snaks[aliasesP.title] and (statement.snaks[aliasesP.referenceURL] or additionalProcessedProperties[aliasesP.referenceURL]) then&lt;br /&gt;
    		additionalProcessedProperties[aliasesP.title] = {self:getReferenceDetail(statement.snaks, aliasesP.subjectNamedAs, false, false, true)}  -- not raw, not linked, anyLang&lt;br /&gt;
    	end&lt;br /&gt;
    	statement.snaks[aliasesP.subjectNamedAs] = nil&lt;br /&gt;
    end&lt;br /&gt;
    &lt;br /&gt;
    -- initialize groupedProcessedProperties and citeParams&lt;br /&gt;
    for _, citeType in ipairs(citeTypes) do&lt;br /&gt;
    	groupedProcessedProperties[citeType] = {}&lt;br /&gt;
    	citeParams[citeType] = {}&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
	-- fill groupedProcessedProperties&lt;br /&gt;
	for refProperty in pairs(statement.snaks) do&lt;br /&gt;
		-- add the parameter to each matching type of citation&lt;br /&gt;
		for _, citeType in ipairs(citeTypes) do&lt;br /&gt;
			repeat  -- just a simple wrapper to emulate &amp;quot;continue&amp;quot;&lt;br /&gt;
				-- skip if there already have been errors&lt;br /&gt;
				if citeErrors[citeType] then&lt;br /&gt;
					break&lt;br /&gt;
				end&lt;br /&gt;
				&lt;br /&gt;
				-- set mappingKey and prefix&lt;br /&gt;
				local mappingKey&lt;br /&gt;
				local prefix = &amp;quot;&amp;quot;&lt;br /&gt;
				if statement.snaks[refProperty][1].datatype == &#039;external-id&#039; then&lt;br /&gt;
					mappingKey = &amp;quot;external-id&amp;quot;&lt;br /&gt;
					prefix = self.conf:getLabel(refProperty)&lt;br /&gt;
		&lt;br /&gt;
					if prefix ~= &amp;quot;&amp;quot; then&lt;br /&gt;
						prefix = prefix .. &amp;quot; &amp;quot;&lt;br /&gt;
					end&lt;br /&gt;
				else&lt;br /&gt;
					mappingKey = refProperty&lt;br /&gt;
				end&lt;br /&gt;
				&lt;br /&gt;
				local paramName = citeParamMapping[citeType][mappingKey]&lt;br /&gt;
				-- skip properties with empty parameter name&lt;br /&gt;
				if paramName == &amp;quot;&amp;quot; then&lt;br /&gt;
					break&lt;br /&gt;
				end&lt;br /&gt;
				&lt;br /&gt;
				referenceEmpty = false&lt;br /&gt;
&lt;br /&gt;
				-- handle unknown properties in the reference&lt;br /&gt;
				if not paramName then&lt;br /&gt;
					local error_message = errorText(&amp;quot;unknown-property-in-ref&amp;quot;, refProperty)&lt;br /&gt;
					assert(error_message)  -- Should not be nil&lt;br /&gt;
					citeErrors[citeType] = error_message&lt;br /&gt;
					break&lt;br /&gt;
				end&lt;br /&gt;
				&lt;br /&gt;
				-- set processedProperty&lt;br /&gt;
				local processedProperty&lt;br /&gt;
				local raw = false  -- if the value is wanted raw&lt;br /&gt;
				if isValueInTable(paramName, citeConfig[citeType][&amp;quot;raw-value-params&amp;quot;] or {}) then&lt;br /&gt;
					raw = true&lt;br /&gt;
				end&lt;br /&gt;
				if isValueInTable(paramName, citeConfig[citeType][&amp;quot;numbered-params&amp;quot;] or {}) then&lt;br /&gt;
					-- Multiple values may be given.&lt;br /&gt;
					processedProperty = self:getReferenceDetails(statement.snaks, refProperty, raw, self.linked, true)  -- anyLang = true&lt;br /&gt;
				else&lt;br /&gt;
					-- If multiple values are given, all but the first suitable one are discarted.&lt;br /&gt;
					processedProperty = {self:getReferenceDetail(statement.snaks, refProperty, raw, self.linked and (statement.snaks[refProperty][1].datatype ~= &#039;url&#039;), true)}  -- link = true/false, anyLang = true&lt;br /&gt;
				end&lt;br /&gt;
		&lt;br /&gt;
				if #processedProperty == 0 then&lt;br /&gt;
					break	&lt;br /&gt;
				end&lt;br /&gt;
                &lt;br /&gt;
                -- add an entry to groupedProcessedProperties&lt;br /&gt;
                if not groupedProcessedProperties[citeType][paramName] then&lt;br /&gt;
                	groupedProcessedProperties[citeType][paramName] = {}&lt;br /&gt;
                end&lt;br /&gt;
                for _, propertyValue in pairs(processedProperty) do&lt;br /&gt;
                	table.insert(groupedProcessedProperties[citeType][paramName], prefix .. propertyValue)&lt;br /&gt;
                end&lt;br /&gt;
            until true&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	-- handle additional properties&lt;br /&gt;
	for refProperty in pairs(additionalProcessedProperties) do&lt;br /&gt;
		for _, citeType in ipairs(citeTypes) do&lt;br /&gt;
			repeat&lt;br /&gt;
				-- skip if there already have been errors&lt;br /&gt;
				if citeErrors[citeType] then&lt;br /&gt;
					break&lt;br /&gt;
				end&lt;br /&gt;
				&lt;br /&gt;
                local paramName = citeParamMapping[citeType][refProperty]&lt;br /&gt;
				-- handle unknown properties in the reference&lt;br /&gt;
				if not paramName then&lt;br /&gt;
					-- Skip this additional property, but do not cause an error.&lt;br /&gt;
					break&lt;br /&gt;
				end&lt;br /&gt;
				if paramName == &amp;quot;&amp;quot; then&lt;br /&gt;
					break&lt;br /&gt;
				end&lt;br /&gt;
				&lt;br /&gt;
				referenceEmpty = false&lt;br /&gt;
                &lt;br /&gt;
                if not groupedProcessedProperties[citeType][paramName] then&lt;br /&gt;
                	groupedProcessedProperties[citeType][paramName] = {}&lt;br /&gt;
                end&lt;br /&gt;
                for _, propertyValue in pairs(additionalProcessedProperties[refProperty]) do&lt;br /&gt;
                	table.insert(groupedProcessedProperties[citeType][paramName], propertyValue)&lt;br /&gt;
                end&lt;br /&gt;
			until true&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	-- fill citeParams&lt;br /&gt;
	for _, citeType in ipairs(citeTypes) do&lt;br /&gt;
		for paramName, paramValues in pairs(groupedProcessedProperties[citeType]) do&lt;br /&gt;
			if #paramValues == 1 or not isValueInTable(paramName, citeConfig[citeType][&amp;quot;numbered-params&amp;quot;] or {}) then&lt;br /&gt;
				citeParams[citeType][paramName] = paramValues[1]&lt;br /&gt;
			else&lt;br /&gt;
				-- There is more than one value for this parameter - the values will&lt;br /&gt;
				-- go into separate numbered parameters (e.g. &amp;quot;author1&amp;quot;, &amp;quot;author2&amp;quot;)&lt;br /&gt;
				for paramNum, paramValue in pairs(paramValues) do&lt;br /&gt;
					citeParams[citeType][paramName .. paramNum] = paramValue&lt;br /&gt;
				end&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	-- handle missing mandatory parameters for the templates&lt;br /&gt;
	for _, citeType in ipairs(citeTypes) do&lt;br /&gt;
		for _, requiredCiteParam in pairs(citeConfig[citeType][&amp;quot;mandatory-params&amp;quot;] or {}) do&lt;br /&gt;
			if not citeParams[citeType][requiredCiteParam] then  -- The required param is not present.&lt;br /&gt;
				if citeErrors[citeType] then  -- Do not override the previous error, if it exists.&lt;br /&gt;
					break&lt;br /&gt;
				end&lt;br /&gt;
				local error_message = errorText(&amp;quot;missing-mandatory-param&amp;quot;, requiredCiteParam)&lt;br /&gt;
				assert(error_message)  -- Should not be nil&lt;br /&gt;
				citeErrors[citeType] = error_message&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	local citeTypeToUse = nil&lt;br /&gt;
&lt;br /&gt;
    -- choose the output template&lt;br /&gt;
    for _, citeType in ipairs(citeTypes) do&lt;br /&gt;
    	if not citeErrors[citeType] then&lt;br /&gt;
    		citeTypeToUse = citeType &lt;br /&gt;
    		break&lt;br /&gt;
    	end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
	-- set refContent&lt;br /&gt;
	local refContent = &amp;quot;&amp;quot;&lt;br /&gt;
	if citeTypeToUse then&lt;br /&gt;
		local templateToUse = citeConfig[citeTypeToUse][&amp;quot;template&amp;quot;]&lt;br /&gt;
		local paramsToUse = citeParams[citeTypeToUse]&lt;br /&gt;
		&lt;br /&gt;
		if not templateToUse or templateToUse == &amp;quot;&amp;quot; then &lt;br /&gt;
			throwError(&amp;quot;no-such-reference-template&amp;quot;, tostring(templateToUse), i18nPath, citeTypeToUse)&lt;br /&gt;
		end&lt;br /&gt;
		&lt;br /&gt;
		-- if this module is being substituted then build a regular template call, otherwise expand the template&lt;br /&gt;
		if mw.isSubsting() then&lt;br /&gt;
			for i, v in pairs(paramsToUse) do&lt;br /&gt;
				refContent = refContent .. &amp;quot;|&amp;quot; .. i .. &amp;quot;=&amp;quot; .. v&lt;br /&gt;
			end&lt;br /&gt;
&lt;br /&gt;
			refContent = &amp;quot;{{&amp;quot; .. templateToUse .. refContent .. &amp;quot;}}&amp;quot;&lt;br /&gt;
		else&lt;br /&gt;
			xpcall(&lt;br /&gt;
				function () refContent = mw.getCurrentFrame():expandTemplate{title=templateToUse, args=paramsToUse} end,&lt;br /&gt;
				function () throwError(&amp;quot;no-such-reference-template&amp;quot;, templateToUse, i18nPath, citeTypeToUse) end&lt;br /&gt;
			)&lt;br /&gt;
		end&lt;br /&gt;
&lt;br /&gt;
	-- If the citation couldn&#039;t be displayed using any template, but is not empty (barring ignored propeties), throw an error.&lt;br /&gt;
	elseif not referenceEmpty then&lt;br /&gt;
		refContent = errorText(&amp;quot;malformed-reference-header&amp;quot;)&lt;br /&gt;
	    for _, citeType in ipairs(citeTypes) do&lt;br /&gt;
	    	refContent = refContent .. errorText(&amp;quot;template-failure-reason&amp;quot;, citeConfig[citeType][&amp;quot;template&amp;quot;], citeErrors[citeType])&lt;br /&gt;
	    end&lt;br /&gt;
		refContent = refContent .. errorText(&amp;quot;malformed-reference-footer&amp;quot;)&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
    -- wrap refContent&lt;br /&gt;
	local ref = {}&lt;br /&gt;
	if refContent ~= &amp;quot;&amp;quot; then&lt;br /&gt;
		ref = {refContent}&lt;br /&gt;
&lt;br /&gt;
		if not self.rawValue then&lt;br /&gt;
			-- this should become a &amp;lt;ref&amp;gt; tag, so save the reference&#039;s hash for later&lt;br /&gt;
			ref.refHash = &amp;quot;wikidata-&amp;quot; .. statement.hash .. &amp;quot;-v&amp;quot; .. (tonumber(i18n[&#039;version&#039;]) + version)&lt;br /&gt;
		end&lt;br /&gt;
		return {ref}&lt;br /&gt;
	else&lt;br /&gt;
		return {}&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- gets a detail of one particular type for a reference&lt;br /&gt;
function State:getReferenceDetail(snaks, dType, raw, link, anyLang)&lt;br /&gt;
	local switchLang = anyLang&lt;br /&gt;
	local value = nil&lt;br /&gt;
&lt;br /&gt;
	if not snaks[dType] then&lt;br /&gt;
		return nil&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- if anyLang, first try the local language and otherwise any language&lt;br /&gt;
	repeat&lt;br /&gt;
		for _, v in ipairs(snaks[dType]) do&lt;br /&gt;
			value = self.conf:getValue(v, raw, link, false, anyLang and not switchLang, false, true)  -- noSpecial = true&lt;br /&gt;
&lt;br /&gt;
			if value then&lt;br /&gt;
				break&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
&lt;br /&gt;
		if value or not anyLang then&lt;br /&gt;
			break&lt;br /&gt;
		end&lt;br /&gt;
&lt;br /&gt;
		switchLang = not switchLang&lt;br /&gt;
	until anyLang and switchLang&lt;br /&gt;
&lt;br /&gt;
	return value&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- gets the details of one particular type for a reference&lt;br /&gt;
function State:getReferenceDetails(snaks, dType, raw, link, anyLang)&lt;br /&gt;
	local values = {}&lt;br /&gt;
&lt;br /&gt;
	if not snaks[dType] then&lt;br /&gt;
		return {}&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	for _, v in ipairs(snaks[dType]) do&lt;br /&gt;
		-- if nil is returned then it will not be added to the table&lt;br /&gt;
		values[#values + 1] = self.conf:getValue(v, raw, link, false, anyLang, false, true)  -- noSpecial = true&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	return values&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- level 1 hook&lt;br /&gt;
function State:getAlias(object)&lt;br /&gt;
	local value = object.value&lt;br /&gt;
	local title = nil&lt;br /&gt;
&lt;br /&gt;
	if value and self.linked then&lt;br /&gt;
		if self.conf.entityID:sub(1,1) == &amp;quot;Q&amp;quot; then&lt;br /&gt;
			title = mw.wikibase.getSitelink(self.conf.entityID)&lt;br /&gt;
		elseif self.conf.entityID:sub(1,1) == &amp;quot;P&amp;quot; then&lt;br /&gt;
			title = &amp;quot;d:Property:&amp;quot; .. self.conf.entityID&lt;br /&gt;
		end&lt;br /&gt;
&lt;br /&gt;
		if title then&lt;br /&gt;
			value = buildWikilink(title, value)&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	value = {value}  -- create one value object&lt;br /&gt;
&lt;br /&gt;
	if #value &amp;gt; 0 then&lt;br /&gt;
		return {value}  -- wrap the value object in an array and return it&lt;br /&gt;
	else&lt;br /&gt;
		return {}  -- return empty array if there was no value&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- level 1 hook&lt;br /&gt;
function State:getBadge(value)&lt;br /&gt;
	value = self.conf:getLabel(value, self.rawValue, self.linked, self.shortName)&lt;br /&gt;
&lt;br /&gt;
	if value == &amp;quot;&amp;quot; then&lt;br /&gt;
		value = nil&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	value = {value}  -- create one value object&lt;br /&gt;
&lt;br /&gt;
	if #value &amp;gt; 0 then&lt;br /&gt;
		return {value}  -- wrap the value object in an array and return it&lt;br /&gt;
	else&lt;br /&gt;
		return {}  -- return empty array if there was no value&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function State:callHook(param, hooks, statement, result)&lt;br /&gt;
	-- call a parameter&#039;s hook if it has been defined and if it has not been called before&lt;br /&gt;
	if not result[param] and hooks[param] then&lt;br /&gt;
		local valuesArray = self[hooks[param]](self, statement, param, result, hooks)  -- array with value objects&lt;br /&gt;
&lt;br /&gt;
		-- add to the result&lt;br /&gt;
		if #valuesArray &amp;gt; 0 then&lt;br /&gt;
			result[param] = valuesArray&lt;br /&gt;
			result.count = result.count + 1&lt;br /&gt;
		else&lt;br /&gt;
			result[param] = {}  -- an empty array to indicate that we&#039;ve tried this hook already&lt;br /&gt;
			return true  -- miss == true&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	return false&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- iterate through claims, claim&#039;s qualifiers or claim&#039;s references to collect values&lt;br /&gt;
function State:iterate(statements, hooks, matchHook)&lt;br /&gt;
	matchHook = matchHook or alwaysTrue&lt;br /&gt;
&lt;br /&gt;
	local matches = false&lt;br /&gt;
	local rankPos = nil&lt;br /&gt;
	local result, gotRequired&lt;br /&gt;
&lt;br /&gt;
	for _, v in ipairs(statements) do&lt;br /&gt;
		-- rankPos will be nil for non-claim statements (e.g. qualifiers, references, etc.)&lt;br /&gt;
		matches, rankPos = matchHook(self, v)&lt;br /&gt;
&lt;br /&gt;
		if matches then&lt;br /&gt;
			result = {count = 0}  -- collection of arrays with value objects&lt;br /&gt;
&lt;br /&gt;
			local function walk(formatTable)&lt;br /&gt;
				local miss&lt;br /&gt;
&lt;br /&gt;
				for i2, v2 in pairs(formatTable.req) do&lt;br /&gt;
					-- call a hook, adding its return value to the result&lt;br /&gt;
					miss = self:callHook(i2, hooks, v, result)&lt;br /&gt;
&lt;br /&gt;
					if miss then&lt;br /&gt;
						-- we miss a required value for this level, so return false&lt;br /&gt;
						return false&lt;br /&gt;
					end&lt;br /&gt;
&lt;br /&gt;
					if result.count == hooks.count then&lt;br /&gt;
						-- we&#039;re done if all hooks have been called;&lt;br /&gt;
						-- returning at this point breaks the loop&lt;br /&gt;
						return true&lt;br /&gt;
					end&lt;br /&gt;
				end&lt;br /&gt;
&lt;br /&gt;
				for _, v2 in ipairs(formatTable) do&lt;br /&gt;
					if result.count == hooks.count then&lt;br /&gt;
						-- we&#039;re done if all hooks have been called;&lt;br /&gt;
						-- returning at this point prevents further childs from being processed&lt;br /&gt;
						return true&lt;br /&gt;
					end&lt;br /&gt;
&lt;br /&gt;
					if v2.child then&lt;br /&gt;
						walk(v2.child)&lt;br /&gt;
					end&lt;br /&gt;
				end&lt;br /&gt;
&lt;br /&gt;
				return true&lt;br /&gt;
			end&lt;br /&gt;
			gotRequired = walk(self.parsedFormat)&lt;br /&gt;
&lt;br /&gt;
			-- only append the result if we got values for all required parameters on the root level&lt;br /&gt;
			if gotRequired then&lt;br /&gt;
				-- if we have a rankPos (only with matchHook() for complete claims), then update the foundRank&lt;br /&gt;
				if rankPos and self.conf.foundRank &amp;gt; rankPos then&lt;br /&gt;
					self.conf.foundRank = rankPos&lt;br /&gt;
				end&lt;br /&gt;
&lt;br /&gt;
				-- append the result&lt;br /&gt;
				self.results[#self.results + 1] = result&lt;br /&gt;
&lt;br /&gt;
				-- break if we only need a single value&lt;br /&gt;
				if self.singleValue then&lt;br /&gt;
					break&lt;br /&gt;
				end&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	return self:out()&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function getEntityId(arg, eid, page, allowOmitPropPrefix, globalSiteId)&lt;br /&gt;
	local id = nil&lt;br /&gt;
	local prop = nil&lt;br /&gt;
&lt;br /&gt;
	if arg then&lt;br /&gt;
		if arg:sub(1,1) == &amp;quot;:&amp;quot; then&lt;br /&gt;
			page = arg&lt;br /&gt;
			eid = nil&lt;br /&gt;
		elseif arg:sub(1,1):upper() == &amp;quot;Q&amp;quot; or arg:sub(1,9):lower() == &amp;quot;property:&amp;quot; or allowOmitPropPrefix then&lt;br /&gt;
			eid = arg&lt;br /&gt;
			page = nil&lt;br /&gt;
		else&lt;br /&gt;
			prop = arg&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	if eid then&lt;br /&gt;
		if eid:sub(1,9):lower() == &amp;quot;property:&amp;quot; then&lt;br /&gt;
			id = replaceAlias(mw.text.trim(eid:sub(10)))&lt;br /&gt;
&lt;br /&gt;
			if id:sub(1,1):upper() ~= &amp;quot;P&amp;quot; then&lt;br /&gt;
				id = &amp;quot;&amp;quot;&lt;br /&gt;
			end&lt;br /&gt;
		else&lt;br /&gt;
			id = replaceAlias(eid)&lt;br /&gt;
		end&lt;br /&gt;
	elseif page then&lt;br /&gt;
		if page:sub(1,1) == &amp;quot;:&amp;quot; then&lt;br /&gt;
			page = mw.text.trim(page:sub(2))&lt;br /&gt;
		end&lt;br /&gt;
&lt;br /&gt;
		id = mw.wikibase.getEntityIdForTitle(page, globalSiteId) or &amp;quot;&amp;quot;&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	if not id then&lt;br /&gt;
		id = mw.wikibase.getEntityIdForCurrentPage() or &amp;quot;&amp;quot;&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	id = id:upper()&lt;br /&gt;
&lt;br /&gt;
	if not mw.wikibase.isValidEntityId(id) then&lt;br /&gt;
		id = &amp;quot;&amp;quot;&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	return id, prop&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function nextArg(args)&lt;br /&gt;
	local arg = args[args.pointer]&lt;br /&gt;
&lt;br /&gt;
	if arg then&lt;br /&gt;
		args.pointer = args.pointer + 1&lt;br /&gt;
		return mw.text.trim(arg)&lt;br /&gt;
	else&lt;br /&gt;
		return nil&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function claimCommand(args, funcName)&lt;br /&gt;
	local cfg = Config:new()&lt;br /&gt;
	cfg:processFlagOrCommand(funcName)  -- process first command (== function name)&lt;br /&gt;
&lt;br /&gt;
	local lastArg, parsedFormat, formatParams, claims, value&lt;br /&gt;
	local hooks = {count = 0}&lt;br /&gt;
&lt;br /&gt;
	-- set the date if given;&lt;br /&gt;
	-- must come BEFORE processing the flags&lt;br /&gt;
	if args[p.args.date] then&lt;br /&gt;
		cfg.atDate = {parseDate(args[p.args.date])}&lt;br /&gt;
		cfg.periods = {false, true, false}  -- change default time constraint to &#039;current&#039;&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- process flags and commands&lt;br /&gt;
	repeat&lt;br /&gt;
		lastArg = nextArg(args)&lt;br /&gt;
	until not cfg:processFlagOrCommand(lastArg)&lt;br /&gt;
&lt;br /&gt;
	-- get the entity ID from either the positional argument, the eid argument or the page argument&lt;br /&gt;
	cfg.entityID, cfg.propertyID = getEntityId(lastArg, args[p.args.eid], args[p.args.page], false, args[p.args.globalSiteId])&lt;br /&gt;
&lt;br /&gt;
	if cfg.entityID == &amp;quot;&amp;quot; then&lt;br /&gt;
		return &amp;quot;&amp;quot;  -- we cannot continue without a valid entity ID&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	cfg.entity = mw.wikibase.getEntity(cfg.entityID)&lt;br /&gt;
&lt;br /&gt;
	if not cfg.propertyID then&lt;br /&gt;
		cfg.propertyID = nextArg(args)&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	cfg.propertyID = replaceAlias(cfg.propertyID)&lt;br /&gt;
&lt;br /&gt;
	if not cfg.entity or not cfg.propertyID then&lt;br /&gt;
		return &amp;quot;&amp;quot;  -- we cannot continue without an entity or a property ID&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	cfg.propertyID = cfg.propertyID:upper()&lt;br /&gt;
&lt;br /&gt;
	if not cfg.entity.claims or not cfg.entity.claims[cfg.propertyID] then&lt;br /&gt;
		return &amp;quot;&amp;quot;  -- there is no use to continue without any claims&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	claims = cfg.entity.claims[cfg.propertyID]&lt;br /&gt;
&lt;br /&gt;
	if cfg.states.qualifiersCount &amp;gt; 0 then&lt;br /&gt;
		-- do further processing if &amp;quot;qualifier(s)&amp;quot; command was given&lt;br /&gt;
&lt;br /&gt;
		if #args - args.pointer + 1 &amp;gt; cfg.states.qualifiersCount then&lt;br /&gt;
			-- claim ID or literal value has been given&lt;br /&gt;
&lt;br /&gt;
			cfg.propertyValue = nextArg(args)&lt;br /&gt;
		end&lt;br /&gt;
&lt;br /&gt;
		for i = 1, cfg.states.qualifiersCount do&lt;br /&gt;
			-- check if given qualifier ID is an alias and add it&lt;br /&gt;
			cfg.qualifierIDs[parameters.qualifier..i] = replaceAlias(nextArg(args) or &amp;quot;&amp;quot;):upper()&lt;br /&gt;
		end&lt;br /&gt;
	elseif cfg.states[parameters.reference] then&lt;br /&gt;
		-- do further processing if &amp;quot;reference(s)&amp;quot; command was given&lt;br /&gt;
&lt;br /&gt;
		cfg.propertyValue = nextArg(args)&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- check for special property value &#039;somevalue&#039; or &#039;novalue&#039;&lt;br /&gt;
	if cfg.propertyValue then&lt;br /&gt;
		cfg.propertyValue = replaceSpecialChars(cfg.propertyValue)&lt;br /&gt;
&lt;br /&gt;
		if cfg.propertyValue ~= &amp;quot;&amp;quot; and mw.text.trim(cfg.propertyValue) == &amp;quot;&amp;quot; then&lt;br /&gt;
			cfg.propertyValue = &amp;quot; &amp;quot;  -- single space represents &#039;somevalue&#039;, whereas empty string represents &#039;novalue&#039;&lt;br /&gt;
		else&lt;br /&gt;
			cfg.propertyValue = mw.text.trim(cfg.propertyValue)&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- parse the desired format, or choose an appropriate format&lt;br /&gt;
	if args[&amp;quot;format&amp;quot;] then&lt;br /&gt;
		parsedFormat, formatParams = parseFormat(args[&amp;quot;format&amp;quot;])&lt;br /&gt;
	elseif cfg.states.qualifiersCount &amp;gt; 0 then  -- &amp;quot;qualifier(s)&amp;quot; command given&lt;br /&gt;
		if cfg.states[parameters.property] then  -- &amp;quot;propert(y|ies)&amp;quot; command given&lt;br /&gt;
			parsedFormat, formatParams = parseFormat(formats.propertyWithQualifier)&lt;br /&gt;
		else&lt;br /&gt;
			parsedFormat, formatParams = parseFormat(formats.qualifier)&lt;br /&gt;
		end&lt;br /&gt;
	elseif cfg.states[parameters.property] then  -- &amp;quot;propert(y|ies)&amp;quot; command given&lt;br /&gt;
		parsedFormat, formatParams = parseFormat(formats.property)&lt;br /&gt;
	else  -- &amp;quot;reference(s)&amp;quot; command given&lt;br /&gt;
		parsedFormat, formatParams = parseFormat(formats.reference)&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- if a &amp;quot;qualifier(s)&amp;quot; command and no &amp;quot;propert(y|ies)&amp;quot; command has been given, make the movable separator a semicolon&lt;br /&gt;
	if cfg.states.qualifiersCount &amp;gt; 0 and not cfg.states[parameters.property] then&lt;br /&gt;
		cfg.separators[&amp;quot;sep&amp;quot;..parameters.separator][1] = {&amp;quot;;&amp;quot;}&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- if only &amp;quot;reference(s)&amp;quot; has been given, set the default separator to none (except when raw)&lt;br /&gt;
	if cfg.states[parameters.reference] and not cfg.states[parameters.property] and cfg.states.qualifiersCount == 0&lt;br /&gt;
	   and not cfg.states[parameters.reference].rawValue then&lt;br /&gt;
		cfg.separators[&amp;quot;sep&amp;quot;][1] = nil&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- if exactly one &amp;quot;qualifier(s)&amp;quot; command has been given, make &amp;quot;sep%q&amp;quot; point to &amp;quot;sep%q1&amp;quot; to make them equivalent&lt;br /&gt;
	if cfg.states.qualifiersCount == 1 then&lt;br /&gt;
		cfg.separators[&amp;quot;sep&amp;quot;..parameters.qualifier] = cfg.separators[&amp;quot;sep&amp;quot;..parameters.qualifier..&amp;quot;1&amp;quot;]&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- process overridden separator values;&lt;br /&gt;
	-- must come AFTER tweaking the default separators&lt;br /&gt;
	cfg:processSeparators(args)&lt;br /&gt;
&lt;br /&gt;
	-- define the hooks that should be called (getProperty, getQualifiers, getReferences);&lt;br /&gt;
	-- only define a hook if both its command (&amp;quot;propert(y|ies)&amp;quot;, &amp;quot;reference(s)&amp;quot;, &amp;quot;qualifier(s)&amp;quot;) and its parameter (&amp;quot;%p&amp;quot;, &amp;quot;%r&amp;quot;, &amp;quot;%q1&amp;quot;, &amp;quot;%q2&amp;quot;, &amp;quot;%q3&amp;quot;) have been given&lt;br /&gt;
	for i, v in pairs(cfg.states) do&lt;br /&gt;
		-- e.g. &#039;formatParams[&amp;quot;%q1&amp;quot;] or formatParams[&amp;quot;%q&amp;quot;]&#039; to define hook even if &amp;quot;%q1&amp;quot; was not defined to be able to build a complete value for &amp;quot;%q&amp;quot;&lt;br /&gt;
		if formatParams[i] or formatParams[i:sub(1, 2)] then&lt;br /&gt;
			hooks[i] = getHookName(i, 1)&lt;br /&gt;
			hooks.count = hooks.count + 1&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- the &amp;quot;%q&amp;quot; parameter is not attached to a state, but is a collection of the results of multiple states (attached to &amp;quot;%q1&amp;quot;, &amp;quot;%q2&amp;quot;, &amp;quot;%q3&amp;quot;, ...);&lt;br /&gt;
	-- so if this parameter is given then this hook must be defined separately, but only if at least one &amp;quot;qualifier(s)&amp;quot; command has been given&lt;br /&gt;
	if formatParams[parameters.qualifier] and cfg.states.qualifiersCount &amp;gt; 0 then&lt;br /&gt;
		hooks[parameters.qualifier] = getHookName(parameters.qualifier, 1)&lt;br /&gt;
		hooks.count = hooks.count + 1&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- create a state for &amp;quot;properties&amp;quot; if it doesn&#039;t exist yet, which will be used as a base configuration for each claim iteration;&lt;br /&gt;
	-- must come AFTER defining the hooks&lt;br /&gt;
	if not cfg.states[parameters.property] then&lt;br /&gt;
		cfg.states[parameters.property] = State:new(cfg, parameters.property)&lt;br /&gt;
&lt;br /&gt;
		-- if the &amp;quot;single&amp;quot; flag has been given then this state should be equivalent to &amp;quot;property&amp;quot; (singular)&lt;br /&gt;
		if cfg.singleClaim then&lt;br /&gt;
			cfg.states[parameters.property].singleValue = true&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- if the &amp;quot;sourced&amp;quot; flag has been given then create a state for &amp;quot;reference&amp;quot; if it doesn&#039;t exist yet, using default values,&lt;br /&gt;
	-- which must exist in order to be able to determine if a claim has any references;&lt;br /&gt;
	-- must come AFTER defining the hooks&lt;br /&gt;
	if cfg.sourcedOnly and not cfg.states[parameters.reference] then&lt;br /&gt;
		cfg:processFlagOrCommand(p.claimCommands.reference)  -- use singular &amp;quot;reference&amp;quot; to minimize overhead&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- set the parsed format and the separators (and optional punctuation mark);&lt;br /&gt;
	-- must come AFTER creating the additonal states&lt;br /&gt;
	cfg:setFormatAndSeparators(cfg.states[parameters.property], parsedFormat)&lt;br /&gt;
&lt;br /&gt;
	-- process qualifier matching values, analogous to cfg.propertyValue&lt;br /&gt;
	for i, v in pairs(args) do&lt;br /&gt;
		i = tostring(i)&lt;br /&gt;
&lt;br /&gt;
		if i:match(&#039;^[Pp]%d+$&#039;) or aliasesP[i] then&lt;br /&gt;
			v = replaceSpecialChars(v)&lt;br /&gt;
&lt;br /&gt;
			-- check for special qualifier value &#039;somevalue&#039;&lt;br /&gt;
			if v ~= &amp;quot;&amp;quot; and mw.text.trim(v) == &amp;quot;&amp;quot; then&lt;br /&gt;
				v = &amp;quot; &amp;quot;  -- single space represents &#039;somevalue&#039;&lt;br /&gt;
			end&lt;br /&gt;
&lt;br /&gt;
			cfg.qualifierIDsAndValues[replaceAlias(i):upper()] = v&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- first sort the claims on rank to pre-define the order of output (preferred first, then normal, then deprecated)&lt;br /&gt;
	claims = sortOnRank(claims)&lt;br /&gt;
&lt;br /&gt;
	-- then iterate through the claims to collect values&lt;br /&gt;
	value = cfg:concatValues(cfg.states[parameters.property]:iterate(claims, hooks, State.claimMatches))  -- pass property state with level 1 hooks and matchHook&lt;br /&gt;
&lt;br /&gt;
	-- if desired, add a clickable icon that may be used to edit the returned values on Wikidata&lt;br /&gt;
	if cfg.editable and value ~= &amp;quot;&amp;quot; then&lt;br /&gt;
		value = value .. cfg:getEditIcon()&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	return value&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function generalCommand(args, funcName)&lt;br /&gt;
	local cfg = Config:new()&lt;br /&gt;
	cfg.curState = State:new(cfg)&lt;br /&gt;
&lt;br /&gt;
	local lastArg&lt;br /&gt;
	local value = nil&lt;br /&gt;
&lt;br /&gt;
	repeat&lt;br /&gt;
		lastArg = nextArg(args)&lt;br /&gt;
	until not cfg:processFlag(lastArg)&lt;br /&gt;
&lt;br /&gt;
	-- get the entity ID from either the positional argument, the eid argument or the page argument&lt;br /&gt;
	cfg.entityID = getEntityId(lastArg, args[p.args.eid], args[p.args.page], true, args[p.args.globalSiteId])&lt;br /&gt;
&lt;br /&gt;
	if cfg.entityID == &amp;quot;&amp;quot; or not mw.wikibase.entityExists(cfg.entityID) then&lt;br /&gt;
		return &amp;quot;&amp;quot;  -- we cannot continue without an entity&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- serve according to the given command&lt;br /&gt;
	if funcName == p.generalCommands.label then&lt;br /&gt;
		value = cfg:getLabel(cfg.entityID, cfg.curState.rawValue, cfg.curState.linked, cfg.curState.shortName)&lt;br /&gt;
	elseif funcName == p.generalCommands.title then&lt;br /&gt;
		cfg.inSitelinks = true&lt;br /&gt;
&lt;br /&gt;
		if cfg.entityID:sub(1,1) == &amp;quot;Q&amp;quot; then&lt;br /&gt;
			value = mw.wikibase.getSitelink(cfg.entityID)&lt;br /&gt;
		end&lt;br /&gt;
&lt;br /&gt;
		if cfg.curState.linked and value then&lt;br /&gt;
			value = buildWikilink(value)&lt;br /&gt;
		end&lt;br /&gt;
	elseif funcName == p.generalCommands.description then&lt;br /&gt;
		value = mw.wikibase.getDescription(cfg.entityID)&lt;br /&gt;
	else&lt;br /&gt;
		local parsedFormat, formatParams&lt;br /&gt;
		local hooks = {count = 0}&lt;br /&gt;
&lt;br /&gt;
		cfg.entity = mw.wikibase.getEntity(cfg.entityID)&lt;br /&gt;
&lt;br /&gt;
		if funcName == p.generalCommands.alias or funcName == p.generalCommands.badge then&lt;br /&gt;
			cfg.curState.singleValue = true&lt;br /&gt;
		end&lt;br /&gt;
&lt;br /&gt;
		if funcName == p.generalCommands.alias or funcName == p.generalCommands.aliases then&lt;br /&gt;
			if not cfg.entity.aliases or not cfg.entity.aliases[cfg.langCode] then&lt;br /&gt;
				return &amp;quot;&amp;quot;  -- there is no use to continue without any aliasses&lt;br /&gt;
			end&lt;br /&gt;
&lt;br /&gt;
			local aliases = cfg.entity.aliases[cfg.langCode]&lt;br /&gt;
&lt;br /&gt;
			-- parse the desired format, or parse the default aliases format&lt;br /&gt;
			if args[&amp;quot;format&amp;quot;] then&lt;br /&gt;
				parsedFormat, formatParams = parseFormat(args[&amp;quot;format&amp;quot;])&lt;br /&gt;
			else&lt;br /&gt;
				parsedFormat, formatParams = parseFormat(formats.alias)&lt;br /&gt;
			end&lt;br /&gt;
&lt;br /&gt;
			-- process overridden separator values;&lt;br /&gt;
			-- must come AFTER tweaking the default separators&lt;br /&gt;
			cfg:processSeparators(args)&lt;br /&gt;
&lt;br /&gt;
			-- define the hook that should be called (getAlias);&lt;br /&gt;
			-- only define the hook if the parameter (&amp;quot;%a&amp;quot;) has been given&lt;br /&gt;
			if formatParams[parameters.alias] then&lt;br /&gt;
				hooks[parameters.alias] = getHookName(parameters.alias, 1)&lt;br /&gt;
				hooks.count = hooks.count + 1&lt;br /&gt;
			end&lt;br /&gt;
&lt;br /&gt;
			-- set the parsed format and the separators (and optional punctuation mark)&lt;br /&gt;
			cfg:setFormatAndSeparators(cfg.curState, parsedFormat)&lt;br /&gt;
&lt;br /&gt;
			-- iterate to collect values&lt;br /&gt;
			value = cfg:concatValues(cfg.curState:iterate(aliases, hooks))&lt;br /&gt;
		elseif funcName == p.generalCommands.badge or funcName == p.generalCommands.badges then&lt;br /&gt;
			if not cfg.entity.sitelinks or not cfg.entity.sitelinks[cfg.siteID] or not cfg.entity.sitelinks[cfg.siteID].badges then&lt;br /&gt;
				return &amp;quot;&amp;quot;  -- there is no use to continue without any badges&lt;br /&gt;
			end&lt;br /&gt;
&lt;br /&gt;
			local badges = cfg.entity.sitelinks[cfg.siteID].badges&lt;br /&gt;
&lt;br /&gt;
			cfg.inSitelinks = true&lt;br /&gt;
&lt;br /&gt;
			-- parse the desired format, or parse the default aliases format&lt;br /&gt;
			if args[&amp;quot;format&amp;quot;] then&lt;br /&gt;
				parsedFormat, formatParams = parseFormat(args[&amp;quot;format&amp;quot;])&lt;br /&gt;
			else&lt;br /&gt;
				parsedFormat, formatParams = parseFormat(formats.badge)&lt;br /&gt;
			end&lt;br /&gt;
&lt;br /&gt;
			-- process overridden separator values;&lt;br /&gt;
			-- must come AFTER tweaking the default separators&lt;br /&gt;
			cfg:processSeparators(args)&lt;br /&gt;
&lt;br /&gt;
			-- define the hook that should be called (getBadge);&lt;br /&gt;
			-- only define the hook if the parameter (&amp;quot;%b&amp;quot;) has been given&lt;br /&gt;
			if formatParams[parameters.badge] then&lt;br /&gt;
				hooks[parameters.badge] = getHookName(parameters.badge, 1)&lt;br /&gt;
				hooks.count = hooks.count + 1&lt;br /&gt;
			end&lt;br /&gt;
&lt;br /&gt;
			-- set the parsed format and the separators (and optional punctuation mark)&lt;br /&gt;
			cfg:setFormatAndSeparators(cfg.curState, parsedFormat)&lt;br /&gt;
&lt;br /&gt;
			-- iterate to collect values&lt;br /&gt;
			value = cfg:concatValues(cfg.curState:iterate(badges, hooks))&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	value = value or &amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
	if cfg.editable and value ~= &amp;quot;&amp;quot; then&lt;br /&gt;
		-- if desired, add a clickable icon that may be used to edit the returned value on Wikidata&lt;br /&gt;
		value = value .. cfg:getEditIcon()&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	return value&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- modules that include this module should call the functions with an underscore prepended, e.g.: p._property(args)&lt;br /&gt;
local function establishCommands(commandList, commandFunc)&lt;br /&gt;
	for _, commandName in pairs(commandList) do&lt;br /&gt;
		local function wikitextWrapper(frame)&lt;br /&gt;
			local args = copyTable(frame.args)&lt;br /&gt;
			args.pointer = 1&lt;br /&gt;
			loadI18n(aliasesP, frame)&lt;br /&gt;
			return commandFunc(args, commandName)&lt;br /&gt;
		end&lt;br /&gt;
		p[commandName] = wikitextWrapper&lt;br /&gt;
&lt;br /&gt;
		local function luaWrapper(args)&lt;br /&gt;
			args = copyTable(args)&lt;br /&gt;
			args.pointer = 1&lt;br /&gt;
			loadI18n(aliasesP)&lt;br /&gt;
			return commandFunc(args, commandName)&lt;br /&gt;
		end&lt;br /&gt;
		p[&amp;quot;_&amp;quot; .. commandName] = luaWrapper&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
establishCommands(p.claimCommands, claimCommand)&lt;br /&gt;
establishCommands(p.generalCommands, generalCommand)&lt;br /&gt;
&lt;br /&gt;
-- main function that is supposed to be used by wrapper templates&lt;br /&gt;
function p.main(frame)&lt;br /&gt;
	if not mw.wikibase then return nil end&lt;br /&gt;
&lt;br /&gt;
	local f, args&lt;br /&gt;
&lt;br /&gt;
	loadI18n(aliasesP, frame)&lt;br /&gt;
&lt;br /&gt;
	-- get the parent frame to take the arguments that were passed to the wrapper template&lt;br /&gt;
	frame = frame:getParent() or frame&lt;br /&gt;
&lt;br /&gt;
	if not frame.args[1] then&lt;br /&gt;
		throwError(&amp;quot;no-function-specified&amp;quot;)&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	f = mw.text.trim(frame.args[1])&lt;br /&gt;
&lt;br /&gt;
	if f == &amp;quot;main&amp;quot; then&lt;br /&gt;
		throwError(&amp;quot;main-called-twice&amp;quot;)&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	assert(p[&amp;quot;_&amp;quot;..f], errorText(&#039;no-such-function&#039;, f))&lt;br /&gt;
&lt;br /&gt;
	-- copy arguments from immutable to mutable table&lt;br /&gt;
	args = copyTable(frame.args)&lt;br /&gt;
&lt;br /&gt;
	-- remove the function name from the list&lt;br /&gt;
	table.remove(args, 1)&lt;br /&gt;
&lt;br /&gt;
	return p[&amp;quot;_&amp;quot;..f](args)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
return p&lt;/div&gt;</summary>
		<author><name>Marie</name></author>
	</entry>
	<entry>
		<id>http://project-au.w.kmwc.org/index.php?title=Module:WikidataIB&amp;diff=2087</id>
		<title>Module:WikidataIB</title>
		<link rel="alternate" type="text/html" href="http://project-au.w.kmwc.org/index.php?title=Module:WikidataIB&amp;diff=2087"/>
		<updated>2026-01-16T10:07:18Z</updated>

		<summary type="html">&lt;p&gt;Marie: 1 revision imported&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;-- Version: 2023-07-10&lt;br /&gt;
-- Module to implement use of a blacklist and whitelist for infobox fields&lt;br /&gt;
-- Can take a named parameter |qid which is the Wikidata ID for the article&lt;br /&gt;
-- if not supplied, it will use the Wikidata ID associated with the current page.&lt;br /&gt;
-- Fields in blacklist are never to be displayed, i.e. module must return nil in all circumstances&lt;br /&gt;
-- Fields in whitelist return local value if it exists or the Wikidata value otherwise&lt;br /&gt;
-- The name of the field that this function is called from is passed in named parameter |name&lt;br /&gt;
-- The name is compulsory when blacklist or whitelist is used,&lt;br /&gt;
-- so the module returns nil if it is not supplied.&lt;br /&gt;
-- blacklist is passed in named parameter |suppressfields (or |spf)&lt;br /&gt;
-- whitelist is passed in named parameter |fetchwikidata (or |fwd)&lt;br /&gt;
&lt;br /&gt;
require(&amp;quot;strict&amp;quot;)&lt;br /&gt;
local p = {}&lt;br /&gt;
&lt;br /&gt;
local cdate -- initialise as nil and only load _complex_date function if needed&lt;br /&gt;
-- Module:Complex date is loaded lazily and has the following dependencies:&lt;br /&gt;
-- Module:Calendar&lt;br /&gt;
-- Module:ISOdate&lt;br /&gt;
-- Module:DateI18n&lt;br /&gt;
-- Module:I18n/complex date&lt;br /&gt;
-- Module:Ordinal&lt;br /&gt;
-- Module:I18n/ordinal&lt;br /&gt;
-- Module:Yesno&lt;br /&gt;
-- Module:Formatnum&lt;br /&gt;
-- Module:Linguistic&lt;br /&gt;
--&lt;br /&gt;
-- The following, taken from https://www.mediawiki.org/wiki/Wikibase/DataModel#Dates_and_times,&lt;br /&gt;
-- is needed to use Module:Complex date which seemingly requires date precision as a string.&lt;br /&gt;
-- It would work better if only the authors of the mediawiki page could spell &#039;millennium&#039;.&lt;br /&gt;
local dp = {&lt;br /&gt;
	[6] = &amp;quot;millennium&amp;quot;,&lt;br /&gt;
	[7] = &amp;quot;century&amp;quot;,&lt;br /&gt;
	[8] = &amp;quot;decade&amp;quot;,&lt;br /&gt;
	[9] = &amp;quot;year&amp;quot;,&lt;br /&gt;
	[10] = &amp;quot;month&amp;quot;,&lt;br /&gt;
	[11] = &amp;quot;day&amp;quot;,&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
local i18n =&lt;br /&gt;
{&lt;br /&gt;
	[&amp;quot;errors&amp;quot;] =&lt;br /&gt;
	{&lt;br /&gt;
		[&amp;quot;property-not-found&amp;quot;] = &amp;quot;Property not found.&amp;quot;,&lt;br /&gt;
		[&amp;quot;No property supplied&amp;quot;] = &amp;quot;No property supplied&amp;quot;,&lt;br /&gt;
		[&amp;quot;entity-not-found&amp;quot;] = &amp;quot;Wikidata entity not found.&amp;quot;,&lt;br /&gt;
		[&amp;quot;unknown-claim-type&amp;quot;] = &amp;quot;Unknown claim type.&amp;quot;,&lt;br /&gt;
		[&amp;quot;unknown-entity-type&amp;quot;] = &amp;quot;Unknown entity type.&amp;quot;,&lt;br /&gt;
		[&amp;quot;qualifier-not-found&amp;quot;] = &amp;quot;Qualifier not found.&amp;quot;,&lt;br /&gt;
		[&amp;quot;site-not-found&amp;quot;] = &amp;quot;Wikimedia project not found.&amp;quot;,&lt;br /&gt;
		[&amp;quot;labels-not-found&amp;quot;] = &amp;quot;No labels found.&amp;quot;,&lt;br /&gt;
		[&amp;quot;descriptions-not-found&amp;quot;] = &amp;quot;No descriptions found.&amp;quot;,&lt;br /&gt;
		[&amp;quot;aliases-not-found&amp;quot;] = &amp;quot;No aliases found.&amp;quot;,&lt;br /&gt;
		[&amp;quot;unknown-datetime-format&amp;quot;] = &amp;quot;Unknown datetime format.&amp;quot;,&lt;br /&gt;
		[&amp;quot;local-article-not-found&amp;quot;] = &amp;quot;Article is available on Wikidata, but not on Wikipedia&amp;quot;,&lt;br /&gt;
		[&amp;quot;dab-page&amp;quot;] = &amp;quot; (dab)&amp;quot;,&lt;br /&gt;
	},&lt;br /&gt;
	[&amp;quot;months&amp;quot;] =&lt;br /&gt;
	{&lt;br /&gt;
		&amp;quot;January&amp;quot;, &amp;quot;February&amp;quot;, &amp;quot;March&amp;quot;, &amp;quot;April&amp;quot;, &amp;quot;May&amp;quot;, &amp;quot;June&amp;quot;,&lt;br /&gt;
		&amp;quot;July&amp;quot;, &amp;quot;August&amp;quot;, &amp;quot;September&amp;quot;, &amp;quot;October&amp;quot;, &amp;quot;November&amp;quot;, &amp;quot;December&amp;quot;&lt;br /&gt;
	},&lt;br /&gt;
	[&amp;quot;century&amp;quot;] = &amp;quot;century&amp;quot;,&lt;br /&gt;
	[&amp;quot;BC&amp;quot;] = &amp;quot;BC&amp;quot;,&lt;br /&gt;
	[&amp;quot;BCE&amp;quot;] = &amp;quot;BCE&amp;quot;,&lt;br /&gt;
	[&amp;quot;ordinal&amp;quot;] =&lt;br /&gt;
	{&lt;br /&gt;
		[1] = &amp;quot;st&amp;quot;,&lt;br /&gt;
		[2] = &amp;quot;nd&amp;quot;,&lt;br /&gt;
		[3] = &amp;quot;rd&amp;quot;,&lt;br /&gt;
		[&amp;quot;default&amp;quot;] = &amp;quot;th&amp;quot;&lt;br /&gt;
	},&lt;br /&gt;
	[&amp;quot;filespace&amp;quot;] = &amp;quot;File&amp;quot;,&lt;br /&gt;
	[&amp;quot;Unknown&amp;quot;] = &amp;quot;Unknown&amp;quot;,&lt;br /&gt;
	[&amp;quot;NaN&amp;quot;] = &amp;quot;Not a number&amp;quot;,&lt;br /&gt;
	-- set the following to the name of a tracking category,&lt;br /&gt;
	-- e.g. &amp;quot;[[Category:Articles with missing Wikidata information]]&amp;quot;, or &amp;quot;&amp;quot; to disable:&lt;br /&gt;
	[&amp;quot;missinginfocat&amp;quot;] = &amp;quot;[[Category:Articles with missing Wikidata information]]&amp;quot;,&lt;br /&gt;
	[&amp;quot;editonwikidata&amp;quot;] = &amp;quot;Edit this on Wikidata&amp;quot;,&lt;br /&gt;
	[&amp;quot;latestdatequalifier&amp;quot;] = function (date) return &amp;quot;before &amp;quot; .. date end,&lt;br /&gt;
	-- some languages, e.g. Bosnian use a period as a suffix after each number in a date&lt;br /&gt;
	[&amp;quot;datenumbersuffix&amp;quot;] = &amp;quot;&amp;quot;,&lt;br /&gt;
	[&amp;quot;list separator&amp;quot;] = &amp;quot;, &amp;quot;,&lt;br /&gt;
	[&amp;quot;multipliers&amp;quot;] = {&lt;br /&gt;
		[0]  = &amp;quot;&amp;quot;,&lt;br /&gt;
		[3]  = &amp;quot; thousand&amp;quot;,&lt;br /&gt;
		[6]  = &amp;quot; million&amp;quot;,&lt;br /&gt;
		[9]  = &amp;quot; billion&amp;quot;,&lt;br /&gt;
		[12] = &amp;quot; trillion&amp;quot;,&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
-- This allows an internationisation module to override the above table&lt;br /&gt;
if &#039;en&#039; ~= mw.getContentLanguage():getCode() then&lt;br /&gt;
	require(&amp;quot;Module:i18n&amp;quot;).loadI18n(&amp;quot;Module:WikidataIB/i18n&amp;quot;, i18n)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- This piece of html implements a collapsible container. Check the classes exist on your wiki.&lt;br /&gt;
local collapsediv = &#039;&amp;lt;div class=&amp;quot;mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%; overflow:auto;&amp;quot; data-expandtext=&amp;quot;{{int:show}}&amp;quot; data-collapsetext=&amp;quot;{{int:hide}}&amp;quot;&amp;gt;&#039;&lt;br /&gt;
&lt;br /&gt;
-- Some items should not be linked.&lt;br /&gt;
-- Each wiki can create a list of those in Module:WikidataIB/nolinks&lt;br /&gt;
-- It should return a table called itemsindex, containing true for each item not to be linked&lt;br /&gt;
local donotlink = {}&lt;br /&gt;
local nolinks_exists, nolinks = pcall(mw.loadData, &amp;quot;Module:WikidataIB/nolinks&amp;quot;)&lt;br /&gt;
if nolinks_exists then&lt;br /&gt;
	donotlink = nolinks.itemsindex&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- To satisfy Wikipedia:Manual of Style/Titles, certain types of items are italicised, and others are quoted.&lt;br /&gt;
-- The submodule [[Module:WikidataIB/titleformats]] lists the entity-ids used in &#039;instance of&#039; (P31),&lt;br /&gt;
-- which allows this module to identify the values that should be formatted.&lt;br /&gt;
-- WikidataIB/titleformats exports a table p.formats, which is indexed by entity-id, and contains the value &amp;quot; or &#039;&#039;&lt;br /&gt;
local formats = {}&lt;br /&gt;
local titleformats_exists, titleformats = pcall(mw.loadData, &amp;quot;Module:WikidataIB/titleformats&amp;quot;)&lt;br /&gt;
if titleformats_exists then&lt;br /&gt;
	formats = titleformats.formats&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
-- Private functions&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
--&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
-- makeOrdinal needs to be internationalised along with the above:&lt;br /&gt;
-- takes cardinal number as a numeric and returns the ordinal as a string&lt;br /&gt;
-- we need three exceptions in English for 1st, 2nd, 3rd, 21st, .. 31st, etc.&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
-- Dependencies: none&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
local makeOrdinal = function(cardinal)&lt;br /&gt;
	local ordsuffix = i18n.ordinal.default&lt;br /&gt;
	if cardinal % 10 == 1 then&lt;br /&gt;
		ordsuffix = i18n.ordinal[1]&lt;br /&gt;
	elseif cardinal % 10 == 2 then&lt;br /&gt;
		ordsuffix = i18n.ordinal[2]&lt;br /&gt;
	elseif cardinal % 10 == 3 then&lt;br /&gt;
		ordsuffix = i18n.ordinal[3]&lt;br /&gt;
	end&lt;br /&gt;
	-- In English, 1, 21, 31, etc. use &#039;st&#039;, but 11, 111, etc. use &#039;th&#039;&lt;br /&gt;
	-- similarly for 12 and 13, etc.&lt;br /&gt;
	if (cardinal % 100 == 11) or (cardinal % 100 == 12) or (cardinal % 100 == 13) then&lt;br /&gt;
		ordsuffix = i18n.ordinal.default&lt;br /&gt;
	end&lt;br /&gt;
	return tostring(cardinal) .. ordsuffix&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
-- findLang takes a &amp;quot;langcode&amp;quot; parameter if supplied and valid&lt;br /&gt;
-- otherwise it tries to create it from the user&#039;s set language ({{int:lang}})&lt;br /&gt;
-- failing that it uses the wiki&#039;s content language.&lt;br /&gt;
-- It returns a language object&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
-- Dependencies: none&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
local findLang = function(langcode)&lt;br /&gt;
	local langobj&lt;br /&gt;
	langcode = mw.text.trim(langcode or &amp;quot;&amp;quot;)&lt;br /&gt;
	if mw.language.isKnownLanguageTag(langcode) then&lt;br /&gt;
		langobj = mw.language.new( langcode )&lt;br /&gt;
	else&lt;br /&gt;
		langcode = mw.getCurrentFrame():callParserFunction(&#039;int&#039;, {&#039;lang&#039;})&lt;br /&gt;
		if mw.language.isKnownLanguageTag(langcode) then&lt;br /&gt;
			langobj = mw.language.new( langcode )&lt;br /&gt;
		else&lt;br /&gt;
			langobj = mw.language.getContentLanguage()&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	return langobj&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
-- _getItemLangCode takes a qid parameter (using the current page&#039;s qid if blank)&lt;br /&gt;
-- If the item for that qid has property country (P17) it looks at the first preferred value&lt;br /&gt;
-- If the country has an official language (P37), it looks at the first preferred value&lt;br /&gt;
-- If that official language has a language code (P424), it returns the first preferred value&lt;br /&gt;
-- Otherwise it returns nothing.&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
-- Dependencies: none&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
local _getItemLangCode = function(qid)&lt;br /&gt;
	qid = mw.text.trim(qid or &amp;quot;&amp;quot;):upper()&lt;br /&gt;
	if qid == &amp;quot;&amp;quot; then qid = mw.wikibase.getEntityIdForCurrentPage() end&lt;br /&gt;
	if not qid then return end&lt;br /&gt;
	local prop17 = mw.wikibase.getBestStatements(qid, &amp;quot;P17&amp;quot;)[1]&lt;br /&gt;
	if not prop17 or prop17.mainsnak.snaktype ~= &amp;quot;value&amp;quot; then return end&lt;br /&gt;
	local qid17 = prop17.mainsnak.datavalue.value.id&lt;br /&gt;
	local prop37 = mw.wikibase.getBestStatements(qid17, &amp;quot;P37&amp;quot;)[1]&lt;br /&gt;
	if not prop37 or prop37.mainsnak.snaktype ~= &amp;quot;value&amp;quot; then return end&lt;br /&gt;
	local qid37 = prop37.mainsnak.datavalue.value.id&lt;br /&gt;
	local prop424 = mw.wikibase.getBestStatements(qid37, &amp;quot;P424&amp;quot;)[1]&lt;br /&gt;
	if not prop424 or prop424.mainsnak.snaktype ~= &amp;quot;value&amp;quot; then return end&lt;br /&gt;
	return prop424.mainsnak.datavalue.value&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
-- roundto takes a number (x)&lt;br /&gt;
-- and returns it rounded to (sf) significant figures&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
-- Dependencies: none&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
local roundto = function(x, sf)&lt;br /&gt;
	if x == 0 then return 0 end&lt;br /&gt;
	local s = 1&lt;br /&gt;
	if x &amp;lt; 0 then&lt;br /&gt;
		x = -x&lt;br /&gt;
		s = -1&lt;br /&gt;
	end&lt;br /&gt;
	if sf &amp;lt; 1 then sf = 1 end&lt;br /&gt;
	local p = 10 ^ (math.floor(math.log10(x)) - sf + 1)&lt;br /&gt;
	x = math.floor(x / p + 0.5) * p * s&lt;br /&gt;
	-- if it&#039;s integral, cast to an integer:&lt;br /&gt;
	if x == math.floor(x) then x = math.floor(x) end&lt;br /&gt;
	return x&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
-- decimalToDMS takes a decimal degrees (x) with precision (p)&lt;br /&gt;
-- and returns degrees/minutes/seconds according to the precision&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
-- Dependencies: none&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
local decimalToDMS = function(x, p)&lt;br /&gt;
	-- if p is not supplied, use a precision around 0.1 seconds&lt;br /&gt;
	if not tonumber(p) then p = 1e-4 end&lt;br /&gt;
	local d = math.floor(x)&lt;br /&gt;
	local ms = (x - d) * 60&lt;br /&gt;
	if p &amp;gt; 0.5 then -- precision is &amp;gt; 1/2 a degree&lt;br /&gt;
		if ms &amp;gt; 30 then d = d + 1 end&lt;br /&gt;
		ms = 0&lt;br /&gt;
	end&lt;br /&gt;
	local m = math.floor(ms)&lt;br /&gt;
	local s = (ms - m) * 60&lt;br /&gt;
	if p &amp;gt; 0.008 then -- precision is &amp;gt; 1/2 a minute&lt;br /&gt;
		if s &amp;gt; 30 then m = m +1 end&lt;br /&gt;
		s = 0&lt;br /&gt;
	elseif p &amp;gt; 0.00014 then -- precision is &amp;gt; 1/2 a second&lt;br /&gt;
		s = math.floor(s + 0.5)&lt;br /&gt;
	elseif p &amp;gt; 0.000014 then -- precision is &amp;gt; 1/20 second&lt;br /&gt;
		s = math.floor(10 * s + 0.5) / 10&lt;br /&gt;
	elseif p &amp;gt; 0.0000014 then -- precision is &amp;gt; 1/200 second&lt;br /&gt;
		s = math.floor(100 * s + 0.5) / 100&lt;br /&gt;
	else -- cap it at 3 dec places for now&lt;br /&gt;
		s = math.floor(1000 * s + 0.5) / 1000&lt;br /&gt;
	end&lt;br /&gt;
	return d, m, s&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
-- decimalPrecision takes a decimal (x) with precision (p)&lt;br /&gt;
-- and returns x rounded approximately to the given precision&lt;br /&gt;
-- precision should be between 1 and 1e-6, preferably a power of 10.&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
-- Dependencies: none&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
local decimalPrecision = function(x, p)&lt;br /&gt;
	local s = 1&lt;br /&gt;
	if x &amp;lt; 0 then&lt;br /&gt;
		x = -x&lt;br /&gt;
		s = -1&lt;br /&gt;
	end&lt;br /&gt;
	-- if p is not supplied, pick an arbitrary precision&lt;br /&gt;
	if not tonumber(p) then p = 1e-4&lt;br /&gt;
	elseif p &amp;gt; 1 then p = 1&lt;br /&gt;
	elseif p &amp;lt; 1e-6 then p = 1e-6&lt;br /&gt;
	else p = 10 ^ math.floor(math.log10(p))&lt;br /&gt;
	end&lt;br /&gt;
	x = math.floor(x / p + 0.5) * p * s&lt;br /&gt;
	-- if it&#039;s integral, cast to an integer:&lt;br /&gt;
	if  x == math.floor(x) then x = math.floor(x) end&lt;br /&gt;
	-- if it&#039;s less than 1e-4, it will be in exponent form, so return a string with 6dp&lt;br /&gt;
	-- 9e-5 becomes 0.000090&lt;br /&gt;
	if math.abs(x) &amp;lt; 1e-4 then x = string.format(&amp;quot;%f&amp;quot;, x) end&lt;br /&gt;
	return x&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
-- formatDate takes a datetime of the usual format from mw.wikibase.entity:formatPropertyValues&lt;br /&gt;
-- like &amp;quot;1 August 30 BCE&amp;quot; as parameter 1&lt;br /&gt;
-- and formats it according to the df (date format) and bc parameters&lt;br /&gt;
-- df = [&amp;quot;dmy&amp;quot; / &amp;quot;mdy&amp;quot; / &amp;quot;y&amp;quot;] default will be &amp;quot;dmy&amp;quot;&lt;br /&gt;
-- bc = [&amp;quot;BC&amp;quot; / &amp;quot;BCE&amp;quot;] default will be &amp;quot;BCE&amp;quot;&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
-- Dependencies: none&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
local format_Date = function(datetime, dateformat, bc)&lt;br /&gt;
	local datetime = datetime or &amp;quot;1 August 30 BCE&amp;quot; -- in case of nil value&lt;br /&gt;
	-- chop off multiple vales and/or any hours, mins, etc.&lt;br /&gt;
	-- keep anything before punctuation - we just want a single date:&lt;br /&gt;
	local dateval = string.match( datetime, &amp;quot;[%w ]+&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
	local dateformat = string.lower(dateformat or &amp;quot;dmy&amp;quot;) -- default to dmy&lt;br /&gt;
&lt;br /&gt;
	local bc = string.upper(bc or &amp;quot;&amp;quot;) -- can&#039;t use nil for bc&lt;br /&gt;
	-- we only want to accept two possibilities: BC or default to BCE&lt;br /&gt;
	if bc == &amp;quot;BC&amp;quot; then&lt;br /&gt;
		bc = &amp;quot;&amp;amp;nbsp;&amp;quot; .. i18n[&amp;quot;BC&amp;quot;] -- prepend a non-breaking space.&lt;br /&gt;
	else&lt;br /&gt;
		bc = &amp;quot;&amp;amp;nbsp;&amp;quot; .. i18n[&amp;quot;BCE&amp;quot;]&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	local postchrist = true -- start by assuming no BCE&lt;br /&gt;
	local dateparts = {}&lt;br /&gt;
	for word in string.gmatch(dateval, &amp;quot;%w+&amp;quot;) do&lt;br /&gt;
		if word == &amp;quot;BCE&amp;quot; or word == &amp;quot;BC&amp;quot; then -- *** internationalise later ***&lt;br /&gt;
			postchrist = false&lt;br /&gt;
		else&lt;br /&gt;
			-- we&#039;ll keep the parts that are not &#039;BCE&#039; in a table&lt;br /&gt;
			dateparts[#dateparts + 1] = word&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	if postchrist then bc = &amp;quot;&amp;quot; end -- set AD dates to no suffix *** internationalise later ***&lt;br /&gt;
&lt;br /&gt;
	local sep = &amp;quot;&amp;amp;nbsp;&amp;quot; -- separator is nbsp&lt;br /&gt;
	local fdate = table.concat(dateparts, sep) -- set formatted date to same order as input&lt;br /&gt;
&lt;br /&gt;
	-- if we have day month year, check dateformat&lt;br /&gt;
	if #dateparts == 3 then&lt;br /&gt;
		if dateformat == &amp;quot;y&amp;quot; then&lt;br /&gt;
			fdate = dateparts[3]&lt;br /&gt;
		elseif dateformat == &amp;quot;mdy&amp;quot; then&lt;br /&gt;
			fdate = dateparts[2] .. sep .. dateparts[1] .. &amp;quot;,&amp;quot; .. sep .. dateparts[3]&lt;br /&gt;
		end&lt;br /&gt;
	elseif #dateparts == 2 and dateformat == &amp;quot;y&amp;quot; then&lt;br /&gt;
		fdate = dateparts[2]&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	return fdate .. bc&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
-- dateFormat is the handler for properties that are of type &amp;quot;time&amp;quot;&lt;br /&gt;
-- It takes timestamp, precision (6 to 11 per mediawiki), dateformat (y/dmy/mdy), BC format (BC/BCE),&lt;br /&gt;
-- a plaindate switch (yes/no/adj) to en/disable &amp;quot;sourcing circumstances&amp;quot;/use adjectival form,&lt;br /&gt;
-- any qualifiers for the property, the language, and any adjective to use like &#039;before&#039;.&lt;br /&gt;
-- It passes the date through the &amp;quot;complex date&amp;quot; function&lt;br /&gt;
-- and returns a string with the internatonalised date formatted according to preferences.&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
-- Dependencies: findLang(); cdate(); dp[]&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
local dateFormat = function(timestamp, dprec, df, bcf, pd, qualifiers, lang, adj, model)&lt;br /&gt;
	-- output formatting according to preferences (y/dmy/mdy/ymd)&lt;br /&gt;
	df = (df or &amp;quot;&amp;quot;):lower()&lt;br /&gt;
	-- if ymd is required, return the part of the timestamp in YYYY-MM-DD form&lt;br /&gt;
	-- but apply Year zero#Astronomers fix: 1 BC = 0000; 2 BC = -0001; etc.&lt;br /&gt;
	if df == &amp;quot;ymd&amp;quot; then&lt;br /&gt;
		if timestamp:sub(1,1) == &amp;quot;+&amp;quot; then&lt;br /&gt;
			return timestamp:sub(2,11)&lt;br /&gt;
		else&lt;br /&gt;
			local yr = tonumber(timestamp:sub(2,5)) - 1&lt;br /&gt;
			yr = (&amp;quot;000&amp;quot; .. yr):sub(-4)&lt;br /&gt;
			if yr ~= &amp;quot;0000&amp;quot; then yr = &amp;quot;-&amp;quot; .. yr end&lt;br /&gt;
			return yr .. timestamp:sub(6,11)&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	-- A year can be stored like this: &amp;quot;+1872-00-00T00:00:00Z&amp;quot;,&lt;br /&gt;
	-- which is processed here as if it were the day before &amp;quot;+1872-01-01T00:00:00Z&amp;quot;,&lt;br /&gt;
	-- and that&#039;s the last day of 1871, so the year is wrong.&lt;br /&gt;
	-- So fix the month 0, day 0 timestamp to become 1 January instead:&lt;br /&gt;
	timestamp = timestamp:gsub(&amp;quot;%-00%-00T&amp;quot;, &amp;quot;-01-01T&amp;quot;)&lt;br /&gt;
	-- just in case date precision is missing&lt;br /&gt;
	dprec = dprec or 11&lt;br /&gt;
	-- override more precise dates if required dateformat is year alone:&lt;br /&gt;
	if df == &amp;quot;y&amp;quot; and dprec &amp;gt; 9 then dprec = 9 end&lt;br /&gt;
	-- complex date only deals with precisions from 6 to 11, so clip range&lt;br /&gt;
	dprec = dprec&amp;gt;11 and 11 or dprec&lt;br /&gt;
	dprec = dprec&amp;lt;6 and 6 or dprec&lt;br /&gt;
	-- BC format is &amp;quot;BC&amp;quot; or &amp;quot;BCE&amp;quot;&lt;br /&gt;
	bcf = (bcf or &amp;quot;&amp;quot;):upper()&lt;br /&gt;
	-- plaindate only needs the first letter (y/n/a)&lt;br /&gt;
	pd = (pd or &amp;quot;&amp;quot;):sub(1,1):lower()&lt;br /&gt;
	if pd == &amp;quot;&amp;quot; or pd == &amp;quot;n&amp;quot; or pd == &amp;quot;f&amp;quot; or pd == &amp;quot;0&amp;quot; then pd = false end&lt;br /&gt;
	-- in case language isn&#039;t passed&lt;br /&gt;
	lang = lang or findLang().code&lt;br /&gt;
	-- set adj as empty if nil&lt;br /&gt;
	adj = adj or &amp;quot;&amp;quot;&lt;br /&gt;
	-- extract the day, month, year from the timestamp&lt;br /&gt;
	local bc = timestamp:sub(1, 1)==&amp;quot;-&amp;quot; and &amp;quot;BC&amp;quot; or &amp;quot;&amp;quot;&lt;br /&gt;
	local year, month, day = timestamp:match(&amp;quot;[+-](%d*)-(%d*)-(%d*)T&amp;quot;)&lt;br /&gt;
	local iso = tonumber(year) -- if year is missing, let it throw an error&lt;br /&gt;
	-- this will adjust the date format to be compatible with cdate&lt;br /&gt;
	-- possible formats are Y, YY, YYY0, YYYY, YYYY-MM, YYYY-MM-DD&lt;br /&gt;
	if dprec == 6 then iso = math.floor( (iso - 1) / 1000 ) + 1 end&lt;br /&gt;
	if dprec == 7 then iso = math.floor( (iso - 1) / 100 ) + 1 end&lt;br /&gt;
	if dprec == 8 then iso = math.floor( iso / 10 ) .. &amp;quot;0&amp;quot; end&lt;br /&gt;
	if dprec == 10 then iso = year .. &amp;quot;-&amp;quot; .. month end&lt;br /&gt;
	if dprec == 11 then iso = year .. &amp;quot;-&amp;quot; .. month .. &amp;quot;-&amp;quot; .. day end&lt;br /&gt;
	-- add &amp;quot;circa&amp;quot; (Q5727902) from &amp;quot;sourcing circumstances&amp;quot; (P1480)&lt;br /&gt;
	local sc = not pd and qualifiers and qualifiers.P1480&lt;br /&gt;
	if sc then&lt;br /&gt;
		for k1, v1 in pairs(sc) do&lt;br /&gt;
			if v1.datavalue and v1.datavalue.value.id == &amp;quot;Q5727902&amp;quot; then&lt;br /&gt;
				adj = &amp;quot;circa&amp;quot;&lt;br /&gt;
				break&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	-- deal with Julian dates:&lt;br /&gt;
	-- no point in saying that dates before 1582 are Julian - they are by default&lt;br /&gt;
	-- doesn&#039;t make sense for dates less precise than year&lt;br /&gt;
	-- we can suppress it by setting |plaindate, e.g. for use in constructing categories.&lt;br /&gt;
	local calendarmodel = &amp;quot;&amp;quot;&lt;br /&gt;
	if tonumber(year) &amp;gt; 1582&lt;br /&gt;
		and dprec &amp;gt; 8&lt;br /&gt;
		and not pd&lt;br /&gt;
		and model == &amp;quot;http://www.wikidata.org/entity/Q1985786&amp;quot; then&lt;br /&gt;
		calendarmodel = &amp;quot;julian&amp;quot;&lt;br /&gt;
	end&lt;br /&gt;
	if not cdate then&lt;br /&gt;
		cdate = require(&amp;quot;Module:Complex date&amp;quot;)._complex_date&lt;br /&gt;
	end&lt;br /&gt;
	local fdate = cdate(calendarmodel, adj, tostring(iso), dp[dprec], bc, &amp;quot;&amp;quot;, &amp;quot;&amp;quot;, &amp;quot;&amp;quot;, &amp;quot;&amp;quot;, lang, 1)&lt;br /&gt;
	-- this may have QuickStatements info appended to it in a div, so remove that&lt;br /&gt;
	fdate = fdate:gsub(&#039; &amp;lt;div style=&amp;quot;display: none;&amp;quot;&amp;gt;[^&amp;lt;]*&amp;lt;/div&amp;gt;&#039;, &#039;&#039;)&lt;br /&gt;
	-- it may also be returned wrapped in a microformat, so remove that&lt;br /&gt;
	fdate = fdate:gsub(&amp;quot;&amp;lt;[^&amp;gt;]*&amp;gt;&amp;quot;, &amp;quot;&amp;quot;)&lt;br /&gt;
	-- there may be leading zeros that we should remove&lt;br /&gt;
	fdate = fdate:gsub(&amp;quot;^0*&amp;quot;, &amp;quot;&amp;quot;)&lt;br /&gt;
	-- if a plain date is required, then remove any links (like BC linked)&lt;br /&gt;
	if pd then&lt;br /&gt;
		fdate = fdate:gsub(&amp;quot;%[%[.*|&amp;quot;, &amp;quot;&amp;quot;):gsub(&amp;quot;]]&amp;quot;, &amp;quot;&amp;quot;)&lt;br /&gt;
	end&lt;br /&gt;
	-- if &#039;circa&#039;, use the abbreviated form *** internationalise later ***&lt;br /&gt;
	fdate = fdate:gsub(&#039;circa &#039;, &#039;&amp;lt;abbr title=&amp;quot;circa&amp;quot;&amp;gt;c.&amp;lt;/abbr&amp;gt;&amp;amp;nbsp;&#039;)&lt;br /&gt;
	-- deal with BC/BCE&lt;br /&gt;
	if bcf == &amp;quot;BCE&amp;quot; then&lt;br /&gt;
		fdate = fdate:gsub(&#039;BC&#039;, &#039;BCE&#039;)&lt;br /&gt;
	end&lt;br /&gt;
	-- deal with mdy format&lt;br /&gt;
	if df == &amp;quot;mdy&amp;quot; then&lt;br /&gt;
		fdate = fdate:gsub(&amp;quot;(%d+) (%w+) (%d+)&amp;quot;, &amp;quot;%2 %1, %3&amp;quot;)&lt;br /&gt;
	end&lt;br /&gt;
	-- deal with adjectival form *** internationalise later ***&lt;br /&gt;
	if pd == &amp;quot;a&amp;quot; then&lt;br /&gt;
		fdate = fdate:gsub(&#039; century&#039;, &#039;-century&#039;)&lt;br /&gt;
	end&lt;br /&gt;
	return fdate&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
-- parseParam takes a (string) parameter, e.g. from the list of frame arguments,&lt;br /&gt;
-- and makes &amp;quot;false&amp;quot;, &amp;quot;no&amp;quot;, and &amp;quot;0&amp;quot; into the (boolean) false&lt;br /&gt;
-- it makes the empty string and nil into the (boolean) value passed as default&lt;br /&gt;
-- allowing the parameter to be true or false by default.&lt;br /&gt;
-- It returns a boolean.&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
-- Dependencies: none&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
local parseParam = function(param, default)&lt;br /&gt;
	if type(param) == &amp;quot;boolean&amp;quot; then param = tostring(param) end&lt;br /&gt;
	if param and param ~= &amp;quot;&amp;quot; then&lt;br /&gt;
		param = param:lower()&lt;br /&gt;
		if (param == &amp;quot;false&amp;quot;) or (param:sub(1,1) == &amp;quot;n&amp;quot;) or (param == &amp;quot;0&amp;quot;) then&lt;br /&gt;
			return false&lt;br /&gt;
		else&lt;br /&gt;
			return true&lt;br /&gt;
		end&lt;br /&gt;
	else&lt;br /&gt;
		return default&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
-- _getSitelink takes the qid of a Wikidata entity passed as |qid=&lt;br /&gt;
-- It takes an optional parameter |wiki= to determine which wiki is to be checked for a sitelink&lt;br /&gt;
-- If the parameter is blank, then it uses the local wiki.&lt;br /&gt;
-- If there is a sitelink to an article available, it returns the plain text link to the article&lt;br /&gt;
-- If there is no sitelink, it returns nil.&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
-- Dependencies: none&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
local _getSitelink = function(qid, wiki)&lt;br /&gt;
	qid = (qid or &amp;quot;&amp;quot;):upper()&lt;br /&gt;
	if qid == &amp;quot;&amp;quot; then qid = mw.wikibase.getEntityIdForCurrentPage() end&lt;br /&gt;
	if not qid then return nil end&lt;br /&gt;
	wiki = wiki or &amp;quot;&amp;quot;&lt;br /&gt;
	local sitelink&lt;br /&gt;
	if wiki == &amp;quot;&amp;quot; then&lt;br /&gt;
		sitelink = mw.wikibase.getSitelink(qid)&lt;br /&gt;
	else&lt;br /&gt;
		sitelink = mw.wikibase.getSitelink(qid, wiki)&lt;br /&gt;
	end&lt;br /&gt;
	return sitelink&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
-- _getCommonslink takes an optional qid of a Wikidata entity passed as |qid=&lt;br /&gt;
-- It returns one of the following in order of preference:&lt;br /&gt;
-- 	the Commons sitelink of the Wikidata entity - but not if onlycat=true and it&#039;s not a category;&lt;br /&gt;
-- 	the Commons sitelink of the topic&#039;s main category of the Wikidata entity;&lt;br /&gt;
-- 	the Commons category of the Wikidata entity - unless fallback=false.&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
-- Dependencies: _getSitelink(); parseParam()&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
local _getCommonslink = function(qid, onlycat, fallback)&lt;br /&gt;
	qid = (qid or &amp;quot;&amp;quot;):upper()&lt;br /&gt;
	if qid == &amp;quot;&amp;quot; then qid = mw.wikibase.getEntityIdForCurrentPage() end&lt;br /&gt;
	if not qid then return nil end&lt;br /&gt;
	onlycat = parseParam(onlycat, false)&lt;br /&gt;
	if fallback == &amp;quot;&amp;quot; then fallback = nil end&lt;br /&gt;
	local sitelink = _getSitelink(qid, &amp;quot;commonswiki&amp;quot;)&lt;br /&gt;
	if onlycat and sitelink and sitelink:sub(1,9) ~= &amp;quot;Category:&amp;quot; then sitelink = nil end&lt;br /&gt;
	if not sitelink then&lt;br /&gt;
		-- check for topic&#039;s main category&lt;br /&gt;
		local prop910 = mw.wikibase.getBestStatements(qid, &amp;quot;P910&amp;quot;)[1]&lt;br /&gt;
		if prop910 then&lt;br /&gt;
			local tmcid = prop910.mainsnak.datavalue and prop910.mainsnak.datavalue.value.id&lt;br /&gt;
			sitelink = _getSitelink(tmcid, &amp;quot;commonswiki&amp;quot;)&lt;br /&gt;
		end&lt;br /&gt;
		if not sitelink then&lt;br /&gt;
			-- check for list&#039;s main category&lt;br /&gt;
			local prop1754 = mw.wikibase.getBestStatements(qid, &amp;quot;P1754&amp;quot;)[1]&lt;br /&gt;
			if prop1754 then&lt;br /&gt;
				local tmcid = prop1754.mainsnak.datavalue and prop1754.mainsnak.datavalue.value.id&lt;br /&gt;
				sitelink = _getSitelink(tmcid, &amp;quot;commonswiki&amp;quot;)&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	if not sitelink and fallback then&lt;br /&gt;
		-- check for Commons category (string value)&lt;br /&gt;
		local prop373 = mw.wikibase.getBestStatements(qid, &amp;quot;P373&amp;quot;)[1]&lt;br /&gt;
		if prop373 then&lt;br /&gt;
			sitelink = prop373.mainsnak.datavalue and prop373.mainsnak.datavalue.value&lt;br /&gt;
			if sitelink then sitelink = &amp;quot;Category:&amp;quot; .. sitelink end&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	return sitelink&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
-- The label in a Wikidata item is subject to vulnerabilities&lt;br /&gt;
-- that an attacker might try to exploit.&lt;br /&gt;
-- It needs to be &#039;sanitised&#039; by removing any wikitext before use.&lt;br /&gt;
-- If it doesn&#039;t exist, return the id for the item&lt;br /&gt;
-- a second (boolean) value is also returned, value is true when the label exists&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
-- Dependencies: none&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
local labelOrId = function(id, lang)&lt;br /&gt;
	if lang == &amp;quot;default&amp;quot; then lang = findLang().code end&lt;br /&gt;
	local label&lt;br /&gt;
	if lang then&lt;br /&gt;
		label = mw.wikibase.getLabelByLang(id, lang)&lt;br /&gt;
	else&lt;br /&gt;
		label = mw.wikibase.getLabel(id)&lt;br /&gt;
	end&lt;br /&gt;
	if label then&lt;br /&gt;
		return mw.text.nowiki(label), true&lt;br /&gt;
	else&lt;br /&gt;
		return id, false&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
-- linkedItem takes an entity-id and returns a string, linked if possible.&lt;br /&gt;
-- This is the handler for &amp;quot;wikibase-item&amp;quot;. Preferences:&lt;br /&gt;
-- 1. Display linked disambiguated sitelink if it exists&lt;br /&gt;
-- 2. Display linked label if it is a redirect&lt;br /&gt;
-- 3. TBA: Display an inter-language link for the label if it exists other than in default language&lt;br /&gt;
-- 4. Display unlinked label if it exists&lt;br /&gt;
-- 5. Display entity-id for now to indicate a label could be provided&lt;br /&gt;
-- dtxt is text to be used instead of label, or nil.&lt;br /&gt;
-- shortname is boolean switch to use P1813 (short name) instead of label if true.&lt;br /&gt;
-- lang is the current language code.&lt;br /&gt;
-- uselbl is boolean switch to force display of the label instead of the sitelink (default: false)&lt;br /&gt;
-- linkredir is boolean switch to allow linking to a redirect (default: false)&lt;br /&gt;
-- formatvalue is boolean switch to allow formatting as italics or quoted (default: false)&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
-- Dependencies: labelOrId(); donotlink[]&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
local linkedItem = function(id, args)&lt;br /&gt;
	local lprefix = (args.lp or args.lprefix or args.linkprefix or &amp;quot;&amp;quot;):gsub(&#039;&amp;quot;&#039;, &#039;&#039;) -- toughen against nil values passed&lt;br /&gt;
	local lpostfix = (args.lpostfix or &amp;quot;&amp;quot;):gsub(&#039;&amp;quot;&#039;, &#039;&#039;)&lt;br /&gt;
	local prefix = (args.prefix or &amp;quot;&amp;quot;):gsub(&#039;&amp;quot;&#039;, &#039;&#039;)&lt;br /&gt;
	local postfix = (args.postfix or &amp;quot;&amp;quot;):gsub(&#039;&amp;quot;&#039;, &#039;&#039;)&lt;br /&gt;
	local dtxt = args.dtxt&lt;br /&gt;
	local shortname = args.shortname or args.sn&lt;br /&gt;
	local lang = args.lang or &amp;quot;en&amp;quot; -- fallback to default if missing&lt;br /&gt;
	local uselbl = args.uselabel or args.uselbl&lt;br /&gt;
	uselbl = parseParam(uselbl, false)&lt;br /&gt;
	local linkredir = args.linkredir&lt;br /&gt;
	linkredir = parseParam(linkredir, false)&lt;br /&gt;
	local formatvalue = args.formatvalue or args.fv&lt;br /&gt;
	formatvalue = parseParam(formatvalue, false)&lt;br /&gt;
	-- see if item might need italics or quotes&lt;br /&gt;
	local fmt = &amp;quot;&amp;quot;&lt;br /&gt;
	if next(formats) and formatvalue then&lt;br /&gt;
		for k, v in ipairs( mw.wikibase.getBestStatements(id, &amp;quot;P31&amp;quot;) ) do&lt;br /&gt;
			if v.mainsnak.datavalue and formats[v.mainsnak.datavalue.value.id] then&lt;br /&gt;
				fmt = formats[v.mainsnak.datavalue.value.id]&lt;br /&gt;
				break -- pick the first match&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	local disp&lt;br /&gt;
	local sitelink = mw.wikibase.getSitelink(id)&lt;br /&gt;
	local label, islabel&lt;br /&gt;
	if dtxt then&lt;br /&gt;
		label, islabel = dtxt, true&lt;br /&gt;
	elseif shortname then&lt;br /&gt;
		-- see if there is a shortname in our language, and set label to it&lt;br /&gt;
		for k, v in ipairs( mw.wikibase.getBestStatements(id, &amp;quot;P1813&amp;quot;) ) do&lt;br /&gt;
			if v.mainsnak.datavalue.value.language == lang then&lt;br /&gt;
				label, islabel = v.mainsnak.datavalue.value.text, true&lt;br /&gt;
				break&lt;br /&gt;
			end -- test for language match&lt;br /&gt;
		end -- loop through values of short name&lt;br /&gt;
		-- if we have no label set, then there was no shortname available&lt;br /&gt;
		if not islabel then&lt;br /&gt;
			label, islabel = labelOrId(id)&lt;br /&gt;
			shortname = false&lt;br /&gt;
		end&lt;br /&gt;
	else&lt;br /&gt;
		label, islabel = labelOrId(id)&lt;br /&gt;
	end&lt;br /&gt;
	if mw.site.siteName ~= &amp;quot;Wikimedia Commons&amp;quot; then&lt;br /&gt;
		if sitelink then&lt;br /&gt;
			if not (dtxt or shortname) then&lt;br /&gt;
				-- if sitelink and label are the same except for case, no need to process further&lt;br /&gt;
				if sitelink:lower() ~= label:lower() then&lt;br /&gt;
					-- strip any namespace or dab from the sitelink&lt;br /&gt;
					local pos = sitelink:find(&amp;quot;:&amp;quot;) or 0&lt;br /&gt;
					local slink = sitelink&lt;br /&gt;
					if pos &amp;gt; 0 then&lt;br /&gt;
						local pfx = sitelink:sub(1,pos-1)&lt;br /&gt;
						if mw.site.namespaces[pfx] then -- that prefix is a valid namespace, so remove it&lt;br /&gt;
							slink = sitelink:sub(pos+1)&lt;br /&gt;
						end&lt;br /&gt;
					end&lt;br /&gt;
					-- remove stuff after commas or inside parentheses - ie. dabs&lt;br /&gt;
					slink = slink:gsub(&amp;quot;%s%(.+%)$&amp;quot;, &amp;quot;&amp;quot;):gsub(&amp;quot;,.+$&amp;quot;, &amp;quot;&amp;quot;)&lt;br /&gt;
					-- if uselbl is false, use sitelink instead of label&lt;br /&gt;
					if not uselbl then&lt;br /&gt;
						--  use slink as display, preserving label case - find(&amp;quot;^%u&amp;quot;) is true for 1st char uppercase&lt;br /&gt;
						if label:find(&amp;quot;^%u&amp;quot;) then&lt;br /&gt;
							label = slink:gsub(&amp;quot;^(%l)&amp;quot;, string.upper)&lt;br /&gt;
						else&lt;br /&gt;
							label = slink:gsub(&amp;quot;^(%u)&amp;quot;, string.lower)&lt;br /&gt;
						end&lt;br /&gt;
					end&lt;br /&gt;
				end&lt;br /&gt;
			end&lt;br /&gt;
			if donotlink[label] then&lt;br /&gt;
				disp = prefix .. fmt .. label .. fmt .. postfix&lt;br /&gt;
			else&lt;br /&gt;
				disp = &amp;quot;[[&amp;quot; .. lprefix .. sitelink .. lpostfix .. &amp;quot;|&amp;quot; .. prefix .. fmt .. label .. fmt .. postfix .. &amp;quot;]]&amp;quot;&lt;br /&gt;
			end&lt;br /&gt;
		elseif islabel then&lt;br /&gt;
			-- no sitelink, label exists, so check if a redirect with that title exists, if linkredir is true&lt;br /&gt;
			-- display plain label by default&lt;br /&gt;
			disp = prefix .. fmt .. label .. fmt .. postfix&lt;br /&gt;
			if linkredir then&lt;br /&gt;
				local artitle = mw.title.new(label, 0) -- only nil if label has invalid chars&lt;br /&gt;
				if not donotlink[label] and artitle and artitle.redirectTarget then&lt;br /&gt;
					-- there&#039;s a redirect with the same title as the label, so let&#039;s link to that&lt;br /&gt;
					disp = &amp;quot;[[&amp;quot;.. lprefix .. label .. lpostfix .. &amp;quot;|&amp;quot; .. prefix .. fmt .. label .. fmt .. postfix .. &amp;quot;]]&amp;quot;&lt;br /&gt;
				end&lt;br /&gt;
			end -- test if article title exists as redirect on current Wiki&lt;br /&gt;
		else&lt;br /&gt;
			-- no sitelink and no label, so return whatever was returned from labelOrId for now&lt;br /&gt;
			-- add tracking category [[Category:Articles with missing Wikidata information]]&lt;br /&gt;
			-- for enwiki, just return the tracking category&lt;br /&gt;
			if mw.wikibase.getGlobalSiteId() == &amp;quot;enwiki&amp;quot; then&lt;br /&gt;
				disp = i18n.missinginfocat&lt;br /&gt;
			else&lt;br /&gt;
				disp = prefix .. label .. postfix .. i18n.missinginfocat&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
	else&lt;br /&gt;
		local ccat = mw.wikibase.getBestStatements(id, &amp;quot;P373&amp;quot;)[1]&lt;br /&gt;
		if ccat and ccat.mainsnak.datavalue then&lt;br /&gt;
			ccat = ccat.mainsnak.datavalue.value&lt;br /&gt;
			disp = &amp;quot;[[&amp;quot; .. lprefix .. &amp;quot;Category:&amp;quot; .. ccat .. lpostfix .. &amp;quot;|&amp;quot; .. prefix .. label .. postfix .. &amp;quot;]]&amp;quot;&lt;br /&gt;
		elseif sitelink then&lt;br /&gt;
			-- this asumes that if a sitelink exists, then a label also exists&lt;br /&gt;
			disp = &amp;quot;[[&amp;quot; .. lprefix .. sitelink .. lpostfix .. &amp;quot;|&amp;quot; .. prefix .. label .. postfix .. &amp;quot;]]&amp;quot;&lt;br /&gt;
		else&lt;br /&gt;
			-- no sitelink and no Commons cat, so return label from labelOrId for now&lt;br /&gt;
			disp = prefix .. label .. postfix&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	return disp&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
-- sourced takes a table representing a statement that may or may not have references&lt;br /&gt;
-- it looks for a reference sourced to something not containing the word &amp;quot;wikipedia&amp;quot;&lt;br /&gt;
-- it returns a boolean = true if it finds a sourced reference.&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
-- Dependencies: none&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
local sourced = function(claim)&lt;br /&gt;
	if claim.references then&lt;br /&gt;
		for kr, vr in pairs(claim.references) do&lt;br /&gt;
			local ref = mw.wikibase.renderSnaks(vr.snaks)&lt;br /&gt;
			if not ref:find(&amp;quot;Wiki&amp;quot;) then&lt;br /&gt;
				return true&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
-- setRanks takes a flag (parameter passed) that requests the values to return&lt;br /&gt;
-- &amp;quot;b[est]&amp;quot; returns preferred if available, otherwise normal&lt;br /&gt;
-- &amp;quot;p[referred]&amp;quot; returns preferred&lt;br /&gt;
-- &amp;quot;n[ormal]&amp;quot; returns normal&lt;br /&gt;
-- &amp;quot;d[eprecated]&amp;quot; returns deprecated&lt;br /&gt;
-- multiple values are allowed, e.g. &amp;quot;preferred normal&amp;quot; (which is the default)&lt;br /&gt;
-- &amp;quot;best&amp;quot; will override the other flags, and set p and n&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
-- Dependencies: none&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
local setRanks = function(rank)&lt;br /&gt;
	rank = (rank or &amp;quot;&amp;quot;):lower()&lt;br /&gt;
	-- if nothing passed, return preferred and normal&lt;br /&gt;
	-- if rank == &amp;quot;&amp;quot; then rank = &amp;quot;p n&amp;quot; end&lt;br /&gt;
	local ranks = {}&lt;br /&gt;
	for w in string.gmatch(rank, &amp;quot;%a+&amp;quot;) do&lt;br /&gt;
		w = w:sub(1,1)&lt;br /&gt;
		if w == &amp;quot;b&amp;quot; or w == &amp;quot;p&amp;quot; or w == &amp;quot;n&amp;quot; or w == &amp;quot;d&amp;quot; then&lt;br /&gt;
			ranks[w] = true&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	-- check if &amp;quot;best&amp;quot; is requested or no ranks requested; and if so, set preferred and normal&lt;br /&gt;
	if ranks.b or not next(ranks) then&lt;br /&gt;
		ranks.p = true&lt;br /&gt;
		ranks.n = true&lt;br /&gt;
	end&lt;br /&gt;
	return ranks&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
-- parseInput processes the Q-id , the blacklist and the whitelist&lt;br /&gt;
-- if an input parameter is supplied, it returns that and ends the call.&lt;br /&gt;
-- it returns (1) either the qid or nil indicating whether or not the call should continue&lt;br /&gt;
-- and (2) a table containing all of the statements for the propertyID and relevant Qid&lt;br /&gt;
-- if &amp;quot;best&amp;quot; ranks are requested, it returns those instead of all non-deprecated ranks&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
-- Dependencies: none&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
local parseInput = function(frame, input_parm, property_id)&lt;br /&gt;
	-- There may be a local parameter supplied, if it&#039;s blank, set it to nil&lt;br /&gt;
	input_parm = mw.text.trim(input_parm or &amp;quot;&amp;quot;)&lt;br /&gt;
	if input_parm == &amp;quot;&amp;quot; then input_parm = nil end&lt;br /&gt;
&lt;br /&gt;
	-- return nil if Wikidata is not available&lt;br /&gt;
	if not mw.wikibase then return false, input_parm end&lt;br /&gt;
&lt;br /&gt;
	local args = frame.args&lt;br /&gt;
&lt;br /&gt;
	-- can take a named parameter |qid which is the Wikidata ID for the article.&lt;br /&gt;
	-- if it&#039;s not supplied, use the id for the current page&lt;br /&gt;
	local qid = args.qid or &amp;quot;&amp;quot;&lt;br /&gt;
	if qid == &amp;quot;&amp;quot; then qid = mw.wikibase.getEntityIdForCurrentPage() end&lt;br /&gt;
	-- if there&#039;s no Wikidata item for the current page return nil&lt;br /&gt;
	if not qid then return false, input_parm end&lt;br /&gt;
&lt;br /&gt;
	-- The blacklist is passed in named parameter |suppressfields&lt;br /&gt;
	local blacklist = args.suppressfields or args.spf or &amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
	-- The whitelist is passed in named parameter |fetchwikidata&lt;br /&gt;
	local whitelist = args.fetchwikidata or args.fwd or &amp;quot;&amp;quot;&lt;br /&gt;
	if whitelist == &amp;quot;&amp;quot; then whitelist = &amp;quot;NONE&amp;quot; end&lt;br /&gt;
&lt;br /&gt;
	-- The name of the field that this function is called from is passed in named parameter |name&lt;br /&gt;
	local fieldname = args.name or &amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
	if blacklist ~= &amp;quot;&amp;quot; then&lt;br /&gt;
		-- The name is compulsory when blacklist is used, so return nil if it is not supplied&lt;br /&gt;
		if fieldname == &amp;quot;&amp;quot; then return false, nil end&lt;br /&gt;
		-- If this field is on the blacklist, then return nil&lt;br /&gt;
		if blacklist:find(fieldname) then return false, nil end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- If we got this far then we&#039;re not on the blacklist&lt;br /&gt;
	-- The blacklist overrides any locally supplied parameter as well&lt;br /&gt;
	-- If a non-blank input parameter was supplied return it&lt;br /&gt;
	if input_parm then return false, input_parm end&lt;br /&gt;
&lt;br /&gt;
	-- We can filter out non-valid properties&lt;br /&gt;
	if property_id:sub(1,1):upper() ~=&amp;quot;P&amp;quot; or property_id == &amp;quot;P0&amp;quot; then return false, nil end&lt;br /&gt;
&lt;br /&gt;
	-- Otherwise see if this field is on the whitelist:&lt;br /&gt;
	-- needs a bit more logic because find will return its second value = 0 if fieldname is &amp;quot;&amp;quot;&lt;br /&gt;
	-- but nil if fieldname not found on whitelist&lt;br /&gt;
	local _, found = whitelist:find(fieldname)&lt;br /&gt;
	found = ((found or 0) &amp;gt; 0)&lt;br /&gt;
	if whitelist ~= &#039;ALL&#039; and (whitelist:upper() == &amp;quot;NONE&amp;quot; or not found) then&lt;br /&gt;
		return false, nil&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- See what&#039;s on Wikidata (the call always returns a table, but it may be empty):&lt;br /&gt;
	local props = {}&lt;br /&gt;
	if args.reqranks.b then&lt;br /&gt;
		props = mw.wikibase.getBestStatements(qid, property_id)&lt;br /&gt;
	else&lt;br /&gt;
		props = mw.wikibase.getAllStatements(qid, property_id)&lt;br /&gt;
	end&lt;br /&gt;
	if props[1] then&lt;br /&gt;
		return qid, props&lt;br /&gt;
	end&lt;br /&gt;
	-- no property on Wikidata&lt;br /&gt;
	return false, nil&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
-- createicon assembles the &amp;quot;Edit at Wikidata&amp;quot; pen icon.&lt;br /&gt;
-- It returns a wikitext string inside a span class=&amp;quot;penicon&amp;quot;&lt;br /&gt;
-- if entityID is nil or empty, the ID associated with current page is used&lt;br /&gt;
-- langcode and propertyID may be nil or empty&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
-- Dependencies: i18n[];&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
local createicon = function(langcode, entityID, propertyID)&lt;br /&gt;
	langcode = langcode or &amp;quot;&amp;quot;&lt;br /&gt;
	if not entityID or entityID == &amp;quot;&amp;quot; then entityID= mw.wikibase.getEntityIdForCurrentPage() end&lt;br /&gt;
	propertyID = propertyID or &amp;quot;&amp;quot;&lt;br /&gt;
	local icon = &amp;quot;&amp;amp;nbsp;&amp;lt;span class=&#039;penicon autoconfirmed-show&#039;&amp;gt;[[&amp;quot;&lt;br /&gt;
	-- &amp;quot;&amp;amp;nbsp;&amp;lt;span data-bridge-edit-flow=&#039;overwrite&#039; class=&#039;penicon&#039;&amp;gt;[[&amp;quot; -&amp;gt; enable Wikidata Bridge&lt;br /&gt;
	.. i18n[&amp;quot;filespace&amp;quot;]&lt;br /&gt;
	.. &amp;quot;:OOjs UI icon edit-ltr-progressive.svg |frameless |text-top |10px |alt=&amp;quot;&lt;br /&gt;
	.. i18n[&amp;quot;editonwikidata&amp;quot;]&lt;br /&gt;
	.. &amp;quot;|link=https://www.wikidata.org/wiki/&amp;quot; .. entityID&lt;br /&gt;
	if langcode ~= &amp;quot;&amp;quot; then icon = icon .. &amp;quot;?uselang=&amp;quot; .. langcode end&lt;br /&gt;
	if propertyID ~= &amp;quot;&amp;quot; then icon = icon .. &amp;quot;#&amp;quot; .. propertyID end&lt;br /&gt;
	icon = icon .. &amp;quot;|&amp;quot; .. i18n[&amp;quot;editonwikidata&amp;quot;] .. &amp;quot;]]&amp;lt;/span&amp;gt;&amp;quot;&lt;br /&gt;
	return icon&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
-- assembleoutput takes the sequence table containing the property values&lt;br /&gt;
-- and formats it according to switches given. It returns a string or nil.&lt;br /&gt;
-- It uses the entityID (and optionally propertyID) to create a link in the pen icon.&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
-- Dependencies: parseParam();&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
local assembleoutput = function(out, args, entityID, propertyID)&lt;br /&gt;
&lt;br /&gt;
	-- sorted is a boolean passed to enable sorting of the values returned&lt;br /&gt;
	-- if nothing or an empty string is passed set it false&lt;br /&gt;
	-- if &amp;quot;false&amp;quot; or &amp;quot;no&amp;quot; or &amp;quot;0&amp;quot; is passed set it false&lt;br /&gt;
	local sorted = parseParam(args.sorted, false)&lt;br /&gt;
&lt;br /&gt;
	-- noicon is a boolean passed to suppress the trailing &amp;quot;edit at Wikidata&amp;quot; icon&lt;br /&gt;
	-- for use when the value is processed further by the infobox&lt;br /&gt;
	-- if nothing or an empty string is passed set it false&lt;br /&gt;
	-- if &amp;quot;false&amp;quot; or &amp;quot;no&amp;quot; or &amp;quot;0&amp;quot; is passed set it false&lt;br /&gt;
	local noic = parseParam(args.noicon, false)&lt;br /&gt;
&lt;br /&gt;
	-- list is the name of a template that a list of multiple values is passed through&lt;br /&gt;
	-- examples include &amp;quot;hlist&amp;quot; and &amp;quot;ubl&amp;quot;&lt;br /&gt;
	-- setting it to &amp;quot;prose&amp;quot; produces something like &amp;quot;1, 2, 3, and 4&amp;quot;&lt;br /&gt;
	local list = args.list or &amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
	-- sep is a string that is used to separate multiple returned values&lt;br /&gt;
	-- if nothing or an empty string is passed set it to the default&lt;br /&gt;
	-- any double-quotes &amp;quot; are stripped out, so that spaces may be passed&lt;br /&gt;
	-- e.g. |sep=&amp;quot; - &amp;quot;&lt;br /&gt;
	local sepdefault = i18n[&amp;quot;list separator&amp;quot;]&lt;br /&gt;
	local separator = args.sep or &amp;quot;&amp;quot;&lt;br /&gt;
	separator = string.gsub(separator, &#039;&amp;quot;&#039;, &#039;&#039;)&lt;br /&gt;
	if separator == &amp;quot;&amp;quot; then&lt;br /&gt;
		separator = sepdefault&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- collapse is a number that determines the maximum number of returned values&lt;br /&gt;
	-- before the output is collapsed.&lt;br /&gt;
	-- Zero or not a number result in no collapsing (default becomes 0).&lt;br /&gt;
	local collapse = tonumber(args.collapse) or 0&lt;br /&gt;
&lt;br /&gt;
	-- replacetext (rt) is a string that is returned instead of any non-empty Wikidata value&lt;br /&gt;
	-- this is useful for tracking and debugging&lt;br /&gt;
	local replacetext = mw.text.trim(args.rt or args.replacetext or &amp;quot;&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
	-- if there&#039;s anything to return, then return a list&lt;br /&gt;
	-- comma-separated by default, but may be specified by the sep parameter&lt;br /&gt;
	-- optionally specify a hlist or ubl or a prose list, etc.&lt;br /&gt;
	local strout&lt;br /&gt;
	if #out &amp;gt; 0 then&lt;br /&gt;
		if sorted then table.sort(out) end&lt;br /&gt;
		-- if there&#039;s something to display and a pen icon is wanted, add it the end of the last value&lt;br /&gt;
		local hasdisplay = false&lt;br /&gt;
		for i, v in ipairs(out) do&lt;br /&gt;
			if v ~= i18n.missinginfocat then&lt;br /&gt;
				hasdisplay = true&lt;br /&gt;
				break&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
		if not noic and hasdisplay then&lt;br /&gt;
			out[#out] = out[#out] .. createicon(args.langobj.code, entityID, propertyID)&lt;br /&gt;
		end&lt;br /&gt;
		if list == &amp;quot;&amp;quot; then&lt;br /&gt;
			strout = table.concat(out, separator)&lt;br /&gt;
		elseif list:lower() == &amp;quot;prose&amp;quot; then&lt;br /&gt;
			strout = mw.text.listToText( out )&lt;br /&gt;
		else&lt;br /&gt;
			strout = mw.getCurrentFrame():expandTemplate{title = list, args = out}&lt;br /&gt;
		end&lt;br /&gt;
		if collapse &amp;gt;0 and #out &amp;gt; collapse then&lt;br /&gt;
			strout = collapsediv .. strout .. &amp;quot;&amp;lt;/div&amp;gt;&amp;quot;&lt;br /&gt;
		end&lt;br /&gt;
	else&lt;br /&gt;
		strout = nil -- no items had valid reference&lt;br /&gt;
	end&lt;br /&gt;
	if replacetext ~= &amp;quot;&amp;quot; and strout then strout = replacetext end&lt;br /&gt;
	return strout&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
-- rendersnak takes a table (propval) containing the information stored on one property value&lt;br /&gt;
-- and returns the value as a string and its language if monolingual text.&lt;br /&gt;
-- It handles data of type:&lt;br /&gt;
--		wikibase-item&lt;br /&gt;
--		time&lt;br /&gt;
--		string, url, commonsMedia, external-id&lt;br /&gt;
--		quantity&lt;br /&gt;
--		globe-coordinate&lt;br /&gt;
--		monolingualtext&lt;br /&gt;
-- It also requires linked, the link/pre/postfixes, uabbr, and the arguments passed from frame.&lt;br /&gt;
-- The optional filter parameter allows quantities to be be filtered by unit Qid.&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
-- Dependencies: parseParam(); labelOrId(); i18n[]; dateFormat();&lt;br /&gt;
-- roundto(); decimalPrecision(); decimalToDMS(); linkedItem();&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
local rendersnak = function(propval, args, linked, lpre, lpost, pre, post, uabbr, filter)&lt;br /&gt;
	lpre = lpre or &amp;quot;&amp;quot;&lt;br /&gt;
	lpost = lpost or &amp;quot;&amp;quot;&lt;br /&gt;
	pre = pre or &amp;quot;&amp;quot;&lt;br /&gt;
	post = post or &amp;quot;&amp;quot;&lt;br /&gt;
	args.lang = args.lang or findLang().code&lt;br /&gt;
	-- allow values to display a fixed text instead of label&lt;br /&gt;
	local dtxt = args.displaytext or args.dt&lt;br /&gt;
	if dtxt == &amp;quot;&amp;quot; then dtxt = nil end&lt;br /&gt;
	-- switch to use display of short name (P1813) instead of label&lt;br /&gt;
	local shortname = args.shortname or args.sn&lt;br /&gt;
	shortname = parseParam(shortname, false)&lt;br /&gt;
	local snak = propval.mainsnak or propval&lt;br /&gt;
	local dtype = snak.datatype&lt;br /&gt;
	local dv = snak.datavalue&lt;br /&gt;
	dv = dv and dv.value&lt;br /&gt;
	-- value and monolingual text language code returned&lt;br /&gt;
	local val, mlt&lt;br /&gt;
	if propval.rank and not args.reqranks[propval.rank:sub(1, 1)] then&lt;br /&gt;
		-- val is nil: value has a rank that isn&#039;t requested&lt;br /&gt;
		------------------------------------&lt;br /&gt;
	elseif snak.snaktype == &amp;quot;somevalue&amp;quot; then -- value is unknown&lt;br /&gt;
		val = i18n[&amp;quot;Unknown&amp;quot;]&lt;br /&gt;
		------------------------------------&lt;br /&gt;
	elseif snak.snaktype == &amp;quot;novalue&amp;quot; then -- value is none&lt;br /&gt;
		-- val = &amp;quot;No value&amp;quot; -- don&#039;t return anything&lt;br /&gt;
		------------------------------------&lt;br /&gt;
	elseif dtype == &amp;quot;wikibase-item&amp;quot; then -- data type is a wikibase item:&lt;br /&gt;
		-- it&#039;s wiki-linked value, so output as link if enabled and possible&lt;br /&gt;
		local qnumber = dv.id&lt;br /&gt;
		if linked then&lt;br /&gt;
			val = linkedItem(qnumber, args)&lt;br /&gt;
		else -- no link wanted so check for display-text, otherwise test for lang code&lt;br /&gt;
			local label, islabel&lt;br /&gt;
			if dtxt then&lt;br /&gt;
				label = dtxt&lt;br /&gt;
			else&lt;br /&gt;
				label, islabel = labelOrId(qnumber)&lt;br /&gt;
				local langlabel = mw.wikibase.getLabelByLang(qnumber, args.lang)&lt;br /&gt;
				if langlabel then&lt;br /&gt;
					label = mw.text.nowiki( langlabel )&lt;br /&gt;
				end&lt;br /&gt;
			end&lt;br /&gt;
			val = pre .. label .. post&lt;br /&gt;
		end -- test for link required&lt;br /&gt;
		------------------------------------&lt;br /&gt;
	elseif dtype == &amp;quot;time&amp;quot; then -- data type is time:&lt;br /&gt;
		-- time is in timestamp format&lt;br /&gt;
		-- date precision is integer per mediawiki&lt;br /&gt;
		-- output formatting according to preferences (y/dmy/mdy)&lt;br /&gt;
		-- BC format as BC or BCE&lt;br /&gt;
		-- plaindate is passed to disable looking for &amp;quot;sourcing cirumstances&amp;quot;&lt;br /&gt;
		-- or to set the adjectival form&lt;br /&gt;
		-- qualifiers (if any) is a nested table or nil&lt;br /&gt;
		-- lang is given, or user language, or site language&lt;br /&gt;
		--&lt;br /&gt;
		-- Here we can check whether args.df has a value&lt;br /&gt;
		-- If not, use code from Module:Sandbox/RexxS/Getdateformat to set it from templates like {{Use mdy dates}}&lt;br /&gt;
		val = dateFormat(dv.time, dv.precision, args.df, args.bc, args.pd, propval.qualifiers, args.lang, &amp;quot;&amp;quot;, dv.calendarmodel)&lt;br /&gt;
		------------------------------------&lt;br /&gt;
	-- data types which are strings:&lt;br /&gt;
	elseif dtype == &amp;quot;commonsMedia&amp;quot; or dtype == &amp;quot;external-id&amp;quot; or dtype == &amp;quot;string&amp;quot; or dtype == &amp;quot;url&amp;quot; then&lt;br /&gt;
		-- commonsMedia or external-id or string or url&lt;br /&gt;
		-- all have mainsnak.datavalue.value as string&lt;br /&gt;
		if (lpre == &amp;quot;&amp;quot; or lpre == &amp;quot;:&amp;quot;) and lpost == &amp;quot;&amp;quot; then&lt;br /&gt;
			-- don&#039;t link if no linkpre/postfix or linkprefix is just &amp;quot;:&amp;quot;&lt;br /&gt;
			val = pre .. dv .. post&lt;br /&gt;
		elseif dtype == &amp;quot;external-id&amp;quot; then&lt;br /&gt;
			val = &amp;quot;[&amp;quot; .. lpre .. dv .. lpost .. &amp;quot; &amp;quot; .. pre .. dv .. post .. &amp;quot;]&amp;quot;&lt;br /&gt;
		else&lt;br /&gt;
			val = &amp;quot;[[&amp;quot; .. lpre .. dv .. lpost .. &amp;quot;|&amp;quot; .. pre .. dv .. post .. &amp;quot;]]&amp;quot;&lt;br /&gt;
		end -- check for link requested (i.e. either linkprefix or linkpostfix exists)&lt;br /&gt;
		------------------------------------&lt;br /&gt;
	-- data types which are quantities:&lt;br /&gt;
	elseif dtype == &amp;quot;quantity&amp;quot; then&lt;br /&gt;
		-- quantities have mainsnak.datavalue.value.amount and mainsnak.datavalue.value.unit&lt;br /&gt;
		-- the unit is of the form http://www.wikidata.org/entity/Q829073&lt;br /&gt;
		--&lt;br /&gt;
		-- implement a switch to turn on/off numerical formatting later&lt;br /&gt;
		local fnum = true&lt;br /&gt;
		--&lt;br /&gt;
		-- a switch to turn on/off conversions - only for en-wiki&lt;br /&gt;
		local conv = parseParam(args.conv or args.convert, false)&lt;br /&gt;
		-- if we have conversions, we won&#039;t have formatted numbers or scales&lt;br /&gt;
		if conv then&lt;br /&gt;
			uabbr = true&lt;br /&gt;
			fnum = false&lt;br /&gt;
			args.scale = &amp;quot;0&amp;quot;&lt;br /&gt;
		end&lt;br /&gt;
		--&lt;br /&gt;
		-- a switch to turn on/off showing units, default is true&lt;br /&gt;
		local showunits = parseParam(args.su or args.showunits, true)&lt;br /&gt;
		--&lt;br /&gt;
		-- convert amount to a number&lt;br /&gt;
		local amount = tonumber(dv.amount) or i18n[&amp;quot;NaN&amp;quot;]&lt;br /&gt;
		--&lt;br /&gt;
		-- scale factor for millions, billions, etc.&lt;br /&gt;
		local sc = tostring(args.scale or &amp;quot;&amp;quot;):sub(1,1):lower()&lt;br /&gt;
		local scale&lt;br /&gt;
		if sc == &amp;quot;a&amp;quot; then&lt;br /&gt;
			-- automatic scaling&lt;br /&gt;
			if amount &amp;gt; 1e15 then&lt;br /&gt;
				scale = 12&lt;br /&gt;
			elseif amount &amp;gt; 1e12 then&lt;br /&gt;
				scale = 9&lt;br /&gt;
			elseif amount &amp;gt; 1e9 then&lt;br /&gt;
				scale = 6&lt;br /&gt;
			elseif amount &amp;gt; 1e6 then&lt;br /&gt;
				scale = 3&lt;br /&gt;
			else&lt;br /&gt;
				scale = 0&lt;br /&gt;
			end&lt;br /&gt;
		else&lt;br /&gt;
			scale = tonumber(args.scale) or 0&lt;br /&gt;
			if scale &amp;lt; 0 or scale &amp;gt; 12 then scale = 0 end&lt;br /&gt;
			scale = math.floor(scale/3) * 3&lt;br /&gt;
		end&lt;br /&gt;
		local factor = 10^scale&lt;br /&gt;
		amount = amount / factor&lt;br /&gt;
		-- ranges:&lt;br /&gt;
		local range = &amp;quot;&amp;quot;&lt;br /&gt;
		-- check if upper and/or lower bounds are given and significant&lt;br /&gt;
		local upb = tonumber(dv.upperBound)&lt;br /&gt;
		local lowb = tonumber(dv.lowerBound)&lt;br /&gt;
		if upb and lowb then&lt;br /&gt;
			-- differences rounded to 2 sig fig:&lt;br /&gt;
			local posdif = roundto(upb - amount, 2) / factor&lt;br /&gt;
			local negdif = roundto(amount - lowb, 2) / factor&lt;br /&gt;
			upb, lowb = amount + posdif, amount - negdif&lt;br /&gt;
			-- round scaled numbers to integers or 4 sig fig&lt;br /&gt;
			if (scale &amp;gt; 0 or sc == &amp;quot;a&amp;quot;) then&lt;br /&gt;
				if amount &amp;lt; 1e4 then&lt;br /&gt;
					amount = roundto(amount, 4)&lt;br /&gt;
				else&lt;br /&gt;
					amount = math.floor(amount + 0.5)&lt;br /&gt;
				end&lt;br /&gt;
			end&lt;br /&gt;
			if fnum then amount = args.langobj:formatNum( amount ) end&lt;br /&gt;
			if posdif ~= negdif then&lt;br /&gt;
				-- non-symmetrical&lt;br /&gt;
				range = &amp;quot; +&amp;quot; .. posdif .. &amp;quot; -&amp;quot; .. negdif&lt;br /&gt;
			elseif posdif ~= 0 then&lt;br /&gt;
				-- symmetrical and non-zero&lt;br /&gt;
				range = &amp;quot; ±&amp;quot; .. posdif&lt;br /&gt;
			else&lt;br /&gt;
				-- otherwise range is zero, so leave it as &amp;quot;&amp;quot;&lt;br /&gt;
			end&lt;br /&gt;
		else&lt;br /&gt;
			-- round scaled numbers to integers or 4 sig fig&lt;br /&gt;
			if (scale &amp;gt; 0 or sc == &amp;quot;a&amp;quot;) then&lt;br /&gt;
				if amount &amp;lt; 1e4 then&lt;br /&gt;
					amount = roundto(amount, 4)&lt;br /&gt;
				else&lt;br /&gt;
					amount = math.floor(amount + 0.5)&lt;br /&gt;
				end&lt;br /&gt;
			end&lt;br /&gt;
			if fnum then amount = args.langobj:formatNum( amount ) end&lt;br /&gt;
		end&lt;br /&gt;
		-- unit names and symbols:&lt;br /&gt;
		-- extract the qid in the form &#039;Qnnn&#039; from the value.unit url&lt;br /&gt;
		-- and then fetch the label from that - or symbol if unitabbr is true&lt;br /&gt;
		local unit = &amp;quot;&amp;quot;&lt;br /&gt;
		local usep = &amp;quot;&amp;quot;&lt;br /&gt;
		local usym = &amp;quot;&amp;quot;&lt;br /&gt;
		local unitqid = string.match( dv.unit, &amp;quot;(Q%d+)&amp;quot; )&lt;br /&gt;
		if filter and unitqid ~= filter then return nil end&lt;br /&gt;
		if unitqid and showunits then&lt;br /&gt;
			local uname = mw.wikibase.getLabelByLang(unitqid, args.lang) or &amp;quot;&amp;quot;&lt;br /&gt;
			if uname ~= &amp;quot;&amp;quot; then usep, unit = &amp;quot; &amp;quot;, uname end&lt;br /&gt;
			if uabbr then&lt;br /&gt;
				-- see if there&#039;s a unit symbol (P5061)&lt;br /&gt;
				local unitsymbols = mw.wikibase.getBestStatements(unitqid, &amp;quot;P5061&amp;quot;)&lt;br /&gt;
				-- construct fallback table, add local lang and multiple languages&lt;br /&gt;
				local fbtbl = mw.language.getFallbacksFor( args.lang )&lt;br /&gt;
				table.insert( fbtbl, 1, args.lang )&lt;br /&gt;
				table.insert( fbtbl, 1, &amp;quot;mul&amp;quot; )&lt;br /&gt;
				local found = false&lt;br /&gt;
				for idx1, us in ipairs(unitsymbols) do&lt;br /&gt;
					for idx2, fblang in ipairs(fbtbl) do&lt;br /&gt;
						if us.mainsnak.datavalue.value.language == fblang then&lt;br /&gt;
							usym = us.mainsnak.datavalue.value.text&lt;br /&gt;
							found = true&lt;br /&gt;
							break&lt;br /&gt;
						end&lt;br /&gt;
					if found then break end&lt;br /&gt;
					end -- loop through fallback table&lt;br /&gt;
				end -- loop through values of P5061&lt;br /&gt;
				if found then usep, unit = &amp;quot;&amp;amp;nbsp;&amp;quot;, usym end&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
		-- format display:&lt;br /&gt;
		if conv then&lt;br /&gt;
			if range == &amp;quot;&amp;quot; then&lt;br /&gt;
				val = mw.getCurrentFrame():expandTemplate{title = &amp;quot;cvt&amp;quot;, args = {amount, unit}}&lt;br /&gt;
			else&lt;br /&gt;
				val = mw.getCurrentFrame():expandTemplate{title = &amp;quot;cvt&amp;quot;, args = {lowb, &amp;quot;to&amp;quot;, upb, unit}}&lt;br /&gt;
			end&lt;br /&gt;
		elseif unit == &amp;quot;$&amp;quot; or unit == &amp;quot;£&amp;quot; then&lt;br /&gt;
			val = unit .. amount .. range .. i18n.multipliers[scale]&lt;br /&gt;
		else&lt;br /&gt;
			val = amount .. range .. i18n.multipliers[scale] .. usep .. unit&lt;br /&gt;
		end&lt;br /&gt;
		------------------------------------&lt;br /&gt;
	-- datatypes which are global coordinates:&lt;br /&gt;
	elseif dtype == &amp;quot;globe-coordinate&amp;quot; then&lt;br /&gt;
		-- &#039;display&#039; parameter defaults to &amp;quot;inline, title&amp;quot; *** unused for now ***&lt;br /&gt;
		-- local disp = args.display or &amp;quot;&amp;quot;&lt;br /&gt;
		-- if disp == &amp;quot;&amp;quot; then disp = &amp;quot;inline, title&amp;quot; end&lt;br /&gt;
		--&lt;br /&gt;
		-- format parameter switches from deg/min/sec to decimal degrees&lt;br /&gt;
		-- default is deg/min/sec -- decimal degrees needs |format = dec&lt;br /&gt;
		local form = (args.format or &amp;quot;&amp;quot;):lower():sub(1,3)&lt;br /&gt;
		if form ~= &amp;quot;dec&amp;quot; then form = &amp;quot;dms&amp;quot; end -- not needed for now&lt;br /&gt;
		--&lt;br /&gt;
		-- show parameter allows just the latitude, or just the longitude, or both&lt;br /&gt;
		-- to be returned as a signed decimal, ignoring the format parameter.&lt;br /&gt;
		local show = (args.show or &amp;quot;&amp;quot;):lower()&lt;br /&gt;
		if show ~= &amp;quot;longlat&amp;quot; then show = show:sub(1,3) end&lt;br /&gt;
		--&lt;br /&gt;
		local lat, long, prec = dv.latitude, dv.longitude, dv.precision&lt;br /&gt;
		if show == &amp;quot;lat&amp;quot; then&lt;br /&gt;
			val = decimalPrecision(lat, prec)&lt;br /&gt;
		elseif show == &amp;quot;lon&amp;quot; then&lt;br /&gt;
			val = decimalPrecision(long, prec)&lt;br /&gt;
		elseif show == &amp;quot;longlat&amp;quot; then&lt;br /&gt;
			val = decimalPrecision(long, prec) .. &amp;quot;, &amp;quot; .. decimalPrecision(lat, prec)&lt;br /&gt;
		else&lt;br /&gt;
			local ns = &amp;quot;N&amp;quot;&lt;br /&gt;
			local ew = &amp;quot;E&amp;quot;&lt;br /&gt;
			if lat &amp;lt; 0 then&lt;br /&gt;
				ns = &amp;quot;S&amp;quot;&lt;br /&gt;
				lat = - lat&lt;br /&gt;
			end&lt;br /&gt;
			if long &amp;lt; 0 then&lt;br /&gt;
				ew = &amp;quot;W&amp;quot;&lt;br /&gt;
				long = - long&lt;br /&gt;
			end&lt;br /&gt;
			if form == &amp;quot;dec&amp;quot; then&lt;br /&gt;
				lat = decimalPrecision(lat, prec)&lt;br /&gt;
				long = decimalPrecision(long, prec)&lt;br /&gt;
				val = lat .. &amp;quot;°&amp;quot; .. ns .. &amp;quot; &amp;quot; .. long ..  &amp;quot;°&amp;quot; .. ew&lt;br /&gt;
			else&lt;br /&gt;
				local latdeg, latmin, latsec = decimalToDMS(lat, prec)&lt;br /&gt;
				local longdeg, longmin, longsec = decimalToDMS(long, prec)&lt;br /&gt;
&lt;br /&gt;
				if latsec == 0 and longsec == 0 then&lt;br /&gt;
					if latmin == 0 and longmin == 0 then&lt;br /&gt;
						val = latdeg .. &amp;quot;°&amp;quot; .. ns .. &amp;quot; &amp;quot; .. longdeg ..  &amp;quot;°&amp;quot; .. ew&lt;br /&gt;
					else&lt;br /&gt;
						val = latdeg .. &amp;quot;°&amp;quot; .. latmin .. &amp;quot;′&amp;quot; .. ns .. &amp;quot; &amp;quot;&lt;br /&gt;
						val = val .. longdeg .. &amp;quot;°&amp;quot;.. longmin .. &amp;quot;′&amp;quot; .. ew&lt;br /&gt;
					end&lt;br /&gt;
				else&lt;br /&gt;
					val = latdeg .. &amp;quot;°&amp;quot; .. latmin .. &amp;quot;′&amp;quot; .. latsec .. &amp;quot;″&amp;quot; .. ns .. &amp;quot; &amp;quot;&lt;br /&gt;
					val = val .. longdeg .. &amp;quot;°&amp;quot; .. longmin .. &amp;quot;′&amp;quot; .. longsec .. &amp;quot;″&amp;quot; .. ew&lt;br /&gt;
				end&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
		------------------------------------&lt;br /&gt;
	elseif dtype == &amp;quot;monolingualtext&amp;quot; then -- data type is Monolingual text:&lt;br /&gt;
		-- has mainsnak.datavalue.value as a table containing language/text pairs&lt;br /&gt;
		-- collect all the values in &#039;out&#039; and languages in &#039;mlt&#039; and process them later&lt;br /&gt;
		val = pre .. dv.text .. post&lt;br /&gt;
		mlt = dv.language&lt;br /&gt;
		------------------------------------&lt;br /&gt;
	else&lt;br /&gt;
		-- some other data type so write a specific handler&lt;br /&gt;
		val = &amp;quot;unknown data type: &amp;quot; .. dtype&lt;br /&gt;
	end -- of datatype/unknown value/sourced check&lt;br /&gt;
	return val, mlt&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
-- propertyvalueandquals takes a property object, the arguments passed from frame,&lt;br /&gt;
-- and a qualifier propertyID.&lt;br /&gt;
-- It returns a sequence (table) of values representing the values of that property&lt;br /&gt;
-- and qualifiers that match the qualifierID if supplied.&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
-- Dependencies: parseParam(); sourced(); labelOrId(); i18n.latestdatequalifier(); format_Date();&lt;br /&gt;
-- makeOrdinal(); roundto(); decimalPrecision(); decimalToDMS(); assembleoutput();&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
local function propertyvalueandquals(objproperty, args, qualID)&lt;br /&gt;
	-- needs this style of declaration because it&#039;s re-entrant&lt;br /&gt;
&lt;br /&gt;
	-- onlysourced is a boolean passed to return only values sourced to other than Wikipedia&lt;br /&gt;
	-- if nothing or an empty string is passed set it true&lt;br /&gt;
	local onlysrc = parseParam(args.onlysourced or args.osd, true)&lt;br /&gt;
&lt;br /&gt;
	-- linked is a a boolean that enables the link to a local page via sitelink&lt;br /&gt;
	-- if nothing or an empty string is passed set it true&lt;br /&gt;
	local linked = parseParam(args.linked, true)&lt;br /&gt;
&lt;br /&gt;
	-- prefix is a string that may be nil, empty (&amp;quot;&amp;quot;), or a string of characters&lt;br /&gt;
	-- this is prefixed to each value&lt;br /&gt;
	-- useful when when multiple values are returned&lt;br /&gt;
	-- any double-quotes &amp;quot; are stripped out, so that spaces may be passed&lt;br /&gt;
	local prefix = (args.prefix or &amp;quot;&amp;quot;):gsub(&#039;&amp;quot;&#039;, &#039;&#039;)&lt;br /&gt;
&lt;br /&gt;
	-- postfix is a string that may be nil, empty (&amp;quot;&amp;quot;), or a string of characters&lt;br /&gt;
	-- this is postfixed to each value&lt;br /&gt;
	-- useful when when multiple values are returned&lt;br /&gt;
	-- any double-quotes &amp;quot; are stripped out, so that spaces may be passed&lt;br /&gt;
	local postfix = (args.postfix or &amp;quot;&amp;quot;):gsub(&#039;&amp;quot;&#039;, &#039;&#039;)&lt;br /&gt;
&lt;br /&gt;
	-- linkprefix is a string that may be nil, empty (&amp;quot;&amp;quot;), or a string of characters&lt;br /&gt;
	-- this creates a link and is then prefixed to each value&lt;br /&gt;
	-- useful when when multiple values are returned and indirect links are needed&lt;br /&gt;
	-- any double-quotes &amp;quot; are stripped out, so that spaces may be passed&lt;br /&gt;
	local lprefix = (args.linkprefix or args.lp or &amp;quot;&amp;quot;):gsub(&#039;&amp;quot;&#039;, &#039;&#039;)&lt;br /&gt;
&lt;br /&gt;
	-- linkpostfix is a string that may be nil, empty (&amp;quot;&amp;quot;), or a string of characters&lt;br /&gt;
	-- this is postfixed to each value when linking is enabled with lprefix&lt;br /&gt;
	-- useful when when multiple values are returned&lt;br /&gt;
	-- any double-quotes &amp;quot; are stripped out, so that spaces may be passed&lt;br /&gt;
	local lpostfix = (args.linkpostfix or &amp;quot;&amp;quot;):gsub(&#039;&amp;quot;&#039;, &#039;&#039;)&lt;br /&gt;
&lt;br /&gt;
	-- wdlinks is a boolean passed to enable links to Wikidata when no article exists&lt;br /&gt;
	-- if nothing or an empty string is passed set it false&lt;br /&gt;
	local wdl = parseParam(args.wdlinks or args.wdl, false)&lt;br /&gt;
&lt;br /&gt;
	-- unitabbr is a boolean passed to enable unit abbreviations for common units&lt;br /&gt;
	-- if nothing or an empty string is passed set it false&lt;br /&gt;
	local uabbr = parseParam(args.unitabbr or args.uabbr, false)&lt;br /&gt;
&lt;br /&gt;
	-- qualsonly is a boolean passed to return just the qualifiers&lt;br /&gt;
	-- if nothing or an empty string is passed set it false&lt;br /&gt;
	local qualsonly = parseParam(args.qualsonly or args.qo, false)&lt;br /&gt;
&lt;br /&gt;
	-- maxvals is a string that may be nil, empty (&amp;quot;&amp;quot;), or a number&lt;br /&gt;
	-- this determines how many items may be returned when multiple values are available&lt;br /&gt;
	-- setting it = 1 is useful where the returned string is used within another call, e.g. image&lt;br /&gt;
	local maxvals = tonumber(args.maxvals) or 0&lt;br /&gt;
&lt;br /&gt;
	-- pd (plain date) is a string: yes/true/1 | no/false/0 | adj&lt;br /&gt;
	-- to disable/enable &amp;quot;sourcing cirumstances&amp;quot; or use adjectival form for the plain date&lt;br /&gt;
	local pd = args.plaindate or args.pd or &amp;quot;no&amp;quot;&lt;br /&gt;
	args.pd = pd&lt;br /&gt;
&lt;br /&gt;
	-- allow qualifiers to have a different date format; default to year unless qualsonly is set&lt;br /&gt;
	args.qdf = args.qdf or args.qualifierdateformat or args.df or (not qualsonly and &amp;quot;y&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
	local lang = args.lang or findLang().code&lt;br /&gt;
&lt;br /&gt;
    -- qualID is a string list of wanted qualifiers or &amp;quot;ALL&amp;quot;&lt;br /&gt;
    qualID = qualID or &amp;quot;&amp;quot;&lt;br /&gt;
    -- capitalise list of wanted qualifiers and substitute &amp;quot;DATES&amp;quot;&lt;br /&gt;
    qualID = qualID:upper():gsub(&amp;quot;DATES&amp;quot;, &amp;quot;P580, P582&amp;quot;)&lt;br /&gt;
    local allflag = (qualID == &amp;quot;ALL&amp;quot;)&lt;br /&gt;
    -- create table of wanted qualifiers as key&lt;br /&gt;
    local qwanted = {}&lt;br /&gt;
    -- create sequence of wanted qualifiers&lt;br /&gt;
    local qorder = {}&lt;br /&gt;
    for q in mw.text.gsplit(qualID, &amp;quot;%p&amp;quot;) do -- split at punctuation and iterate&lt;br /&gt;
        local qtrim = mw.text.trim(q)&lt;br /&gt;
        if qtrim ~= &amp;quot;&amp;quot; then&lt;br /&gt;
            qwanted[mw.text.trim(q)] = true&lt;br /&gt;
            qorder[#qorder+1] = qtrim&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
    -- qsep is the output separator for rendering qualifier list&lt;br /&gt;
    local qsep = (args.qsep or &amp;quot;&amp;quot;):gsub(&#039;&amp;quot;&#039;, &#039;&#039;)&lt;br /&gt;
    -- qargs are the arguments to supply to assembleoutput()&lt;br /&gt;
    local qargs = {&lt;br /&gt;
        [&amp;quot;osd&amp;quot;]         = &amp;quot;false&amp;quot;,&lt;br /&gt;
        [&amp;quot;linked&amp;quot;]      = tostring(linked),&lt;br /&gt;
        [&amp;quot;prefix&amp;quot;]      = args.qprefix,&lt;br /&gt;
        [&amp;quot;postfix&amp;quot;]     = args.qpostfix,&lt;br /&gt;
        [&amp;quot;linkprefix&amp;quot;]  = args.qlinkprefix or args.qlp,&lt;br /&gt;
        [&amp;quot;linkpostfix&amp;quot;] = args.qlinkpostfix,&lt;br /&gt;
        [&amp;quot;wdl&amp;quot;]         = &amp;quot;false&amp;quot;,&lt;br /&gt;
        [&amp;quot;unitabbr&amp;quot;]    = tostring(uabbr),&lt;br /&gt;
        [&amp;quot;maxvals&amp;quot;]     = 0,&lt;br /&gt;
        [&amp;quot;sorted&amp;quot;]      = tostring(args.qsorted),&lt;br /&gt;
        [&amp;quot;noicon&amp;quot;]      = &amp;quot;true&amp;quot;,&lt;br /&gt;
        [&amp;quot;list&amp;quot;]        = args.qlist,&lt;br /&gt;
        [&amp;quot;sep&amp;quot;]         = qsep,&lt;br /&gt;
        [&amp;quot;langobj&amp;quot;]     = args.langobj,&lt;br /&gt;
        [&amp;quot;lang&amp;quot;]        = args.langobj.code,&lt;br /&gt;
        [&amp;quot;df&amp;quot;]          = args.qdf,&lt;br /&gt;
        [&amp;quot;sn&amp;quot;]          = parseParam(args.qsn or args.qshortname, false),&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
	-- all proper values of a Wikidata property will be the same type as the first&lt;br /&gt;
	-- qualifiers don&#039;t have a mainsnak, properties do&lt;br /&gt;
	local datatype = objproperty[1].datatype or objproperty[1].mainsnak.datatype&lt;br /&gt;
&lt;br /&gt;
	-- out[] holds the a list of returned values for this property&lt;br /&gt;
	-- mlt[] holds the language code if the datatype is monolingual text&lt;br /&gt;
	local out = {}&lt;br /&gt;
	local mlt = {}&lt;br /&gt;
&lt;br /&gt;
	for k, v in ipairs(objproperty) do&lt;br /&gt;
		local hasvalue = true&lt;br /&gt;
		if (onlysrc and not sourced(v)) then&lt;br /&gt;
			-- no value: it isn&#039;t sourced when onlysourced=true&lt;br /&gt;
			hasvalue = false&lt;br /&gt;
		else&lt;br /&gt;
			local val, lcode = rendersnak(v, args, linked, lprefix, lpostfix, prefix, postfix, uabbr)&lt;br /&gt;
			if not val then&lt;br /&gt;
				hasvalue = false -- rank doesn&#039;t match&lt;br /&gt;
			elseif qualsonly and qualID then&lt;br /&gt;
				-- suppress value returned: only qualifiers are requested&lt;br /&gt;
			else&lt;br /&gt;
				out[#out+1], mlt[#out+1] = val, lcode&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
&lt;br /&gt;
		-- See if qualifiers are to be returned:&lt;br /&gt;
		local snak = v.mainsnak or v&lt;br /&gt;
		if hasvalue and v.qualifiers and qualID ~= &amp;quot;&amp;quot; and snak.snaktype~=&amp;quot;novalue&amp;quot; then&lt;br /&gt;
            -- collect all wanted qualifier values returned in qlist, indexed by propertyID&lt;br /&gt;
			local qlist = {}&lt;br /&gt;
			local timestart, timeend = &amp;quot;&amp;quot;, &amp;quot;&amp;quot;&lt;br /&gt;
            -- loop through qualifiers&lt;br /&gt;
            for k1, v1 in pairs(v.qualifiers) do&lt;br /&gt;
                if allflag or qwanted[k1] then&lt;br /&gt;
                    if k1 == &amp;quot;P1326&amp;quot; then&lt;br /&gt;
                        local ts = v1[1].datavalue.value.time&lt;br /&gt;
                        local dp = v1[1].datavalue.value.precision&lt;br /&gt;
                        qlist[k1] = dateFormat(ts, dp, args.qdf, args.bc, pd, &amp;quot;&amp;quot;, lang, &amp;quot;before&amp;quot;)&lt;br /&gt;
                    elseif k1 == &amp;quot;P1319&amp;quot; then&lt;br /&gt;
                        local ts = v1[1].datavalue.value.time&lt;br /&gt;
                        local dp = v1[1].datavalue.value.precision&lt;br /&gt;
                        qlist[k1] = dateFormat(ts, dp, args.qdf, args.bc, pd, &amp;quot;&amp;quot;, lang, &amp;quot;after&amp;quot;)&lt;br /&gt;
                    elseif k1 == &amp;quot;P580&amp;quot; then&lt;br /&gt;
                        timestart = propertyvalueandquals(v1, qargs)[1] or &amp;quot;&amp;quot; -- treat only one start time as valid&lt;br /&gt;
                    elseif k1 == &amp;quot;P582&amp;quot; then&lt;br /&gt;
                        timeend = propertyvalueandquals(v1, qargs)[1] or &amp;quot;&amp;quot; -- treat only one end time as valid&lt;br /&gt;
                    else&lt;br /&gt;
                        local q = assembleoutput(propertyvalueandquals(v1, qargs), qargs)&lt;br /&gt;
                        -- we already deal with circa via &#039;sourcing circumstances&#039; if the datatype was time&lt;br /&gt;
                        -- circa may be either linked or unlinked *** internationalise later ***&lt;br /&gt;
                        if datatype ~= &amp;quot;time&amp;quot; or q ~= &amp;quot;circa&amp;quot; and not (type(q) == &amp;quot;string&amp;quot; and q:find(&amp;quot;circa]]&amp;quot;)) then&lt;br /&gt;
                            qlist[k1] = q&lt;br /&gt;
                        end&lt;br /&gt;
                    end&lt;br /&gt;
                end -- of test for wanted&lt;br /&gt;
            end -- of loop through qualifiers&lt;br /&gt;
            -- set date separator&lt;br /&gt;
			local t = timestart .. timeend&lt;br /&gt;
			-- *** internationalise date separators later ***&lt;br /&gt;
			local dsep = &amp;quot;&amp;amp;ndash;&amp;quot;&lt;br /&gt;
			if t:find(&amp;quot;%s&amp;quot;) or t:find(&amp;quot;&amp;amp;nbsp;&amp;quot;) then dsep = &amp;quot; &amp;amp;ndash; &amp;quot; end&lt;br /&gt;
            -- set the order for the list of qualifiers returned; start time and end time go last&lt;br /&gt;
			if next(qlist) then&lt;br /&gt;
                local qlistout = {}&lt;br /&gt;
                if allflag then&lt;br /&gt;
                    for k2, v2 in pairs(qlist) do&lt;br /&gt;
                        qlistout[#qlistout+1] = v2&lt;br /&gt;
                    end&lt;br /&gt;
                else&lt;br /&gt;
                    for i2, v2 in ipairs(qorder) do&lt;br /&gt;
                        qlistout[#qlistout+1] = qlist[v2]&lt;br /&gt;
                    end&lt;br /&gt;
                end&lt;br /&gt;
                if t ~= &amp;quot;&amp;quot; then&lt;br /&gt;
                    qlistout[#qlistout+1] = timestart .. dsep .. timeend&lt;br /&gt;
                end&lt;br /&gt;
				local qstr = assembleoutput(qlistout, qargs)&lt;br /&gt;
				if qualsonly then&lt;br /&gt;
					out[#out+1] = qstr&lt;br /&gt;
				else&lt;br /&gt;
					out[#out] = out[#out] .. &amp;quot; (&amp;quot; .. qstr .. &amp;quot;)&amp;quot;&lt;br /&gt;
				end&lt;br /&gt;
			elseif t ~= &amp;quot;&amp;quot; then&lt;br /&gt;
				if qualsonly then&lt;br /&gt;
					if timestart == &amp;quot;&amp;quot; then&lt;br /&gt;
						out[#out+1] = timeend&lt;br /&gt;
					elseif timeend == &amp;quot;&amp;quot; then&lt;br /&gt;
						out[#out+1] = timestart&lt;br /&gt;
					else&lt;br /&gt;
						out[#out+1] = timestart .. dsep .. timeend&lt;br /&gt;
					end&lt;br /&gt;
				else&lt;br /&gt;
					out[#out] = out[#out] .. &amp;quot; (&amp;quot; .. timestart .. dsep .. timeend .. &amp;quot;)&amp;quot;&lt;br /&gt;
				end&lt;br /&gt;
			end&lt;br /&gt;
		end -- of test for qualifiers wanted&lt;br /&gt;
&lt;br /&gt;
		if maxvals &amp;gt; 0 and #out &amp;gt;= maxvals then break end&lt;br /&gt;
	end -- of for each value loop&lt;br /&gt;
&lt;br /&gt;
	-- we need to pick one value to return if the datatype was &amp;quot;monolingualtext&amp;quot;&lt;br /&gt;
	-- if there&#039;s only one value, use that&lt;br /&gt;
	-- otherwise look through the fallback languages for a match&lt;br /&gt;
	if datatype == &amp;quot;monolingualtext&amp;quot; and #out &amp;gt;1 then&lt;br /&gt;
		lang = mw.text.split( lang, &#039;-&#039;, true )[1]&lt;br /&gt;
		local fbtbl = mw.language.getFallbacksFor( lang )&lt;br /&gt;
		table.insert( fbtbl, 1, lang )&lt;br /&gt;
		local bestval = &amp;quot;&amp;quot;&lt;br /&gt;
		local found = false&lt;br /&gt;
		for idx1, lang1 in ipairs(fbtbl) do&lt;br /&gt;
			for idx2, lang2 in ipairs(mlt) do&lt;br /&gt;
				if (lang1 == lang2) and not found then&lt;br /&gt;
					bestval = out[idx2]&lt;br /&gt;
					found = true&lt;br /&gt;
					break&lt;br /&gt;
				end&lt;br /&gt;
			end -- loop through values of property&lt;br /&gt;
		end -- loop through fallback languages&lt;br /&gt;
		if found then&lt;br /&gt;
			-- replace output table with a table containing the best value&lt;br /&gt;
			out = { bestval }&lt;br /&gt;
		else&lt;br /&gt;
			-- more than one value and none of them on the list of fallback languages&lt;br /&gt;
			-- sod it, just give them the first one&lt;br /&gt;
			out = { out[1] }&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	return out&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
-- Common code for p.getValueByQual and p.getValueByLang&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
-- Dependencies: parseParam; setRanks; parseInput; sourced; assembleoutput;&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
local _getvaluebyqual = function(frame, qualID, checkvalue)&lt;br /&gt;
&lt;br /&gt;
	-- The property ID that will have a qualifier is the first unnamed parameter&lt;br /&gt;
	local propertyID = mw.text.trim(frame.args[1] or &amp;quot;&amp;quot;)&lt;br /&gt;
	if propertyID == &amp;quot;&amp;quot; then return &amp;quot;no property supplied&amp;quot; end&lt;br /&gt;
&lt;br /&gt;
	if qualID == &amp;quot;&amp;quot; then return &amp;quot;no qualifier supplied&amp;quot; end&lt;br /&gt;
&lt;br /&gt;
	-- onlysourced is a boolean passed to return property values&lt;br /&gt;
	-- only when property values are sourced to something other than Wikipedia&lt;br /&gt;
	-- if nothing or an empty string is passed set it true&lt;br /&gt;
	-- if &amp;quot;false&amp;quot; or &amp;quot;no&amp;quot; or 0 is passed set it false&lt;br /&gt;
	local onlysrc = parseParam(frame.args.onlysourced or frame.args.osd, true)&lt;br /&gt;
&lt;br /&gt;
	-- set the requested ranks flags&lt;br /&gt;
	frame.args.reqranks = setRanks(frame.args.rank)&lt;br /&gt;
&lt;br /&gt;
	-- set a language object and code in the frame.args table&lt;br /&gt;
	frame.args.langobj = findLang(frame.args.lang)&lt;br /&gt;
	frame.args.lang = frame.args.langobj.code&lt;br /&gt;
&lt;br /&gt;
	local args = frame.args&lt;br /&gt;
&lt;br /&gt;
	-- check for locally supplied parameter in second unnamed parameter&lt;br /&gt;
	-- success means no local parameter and the property exists&lt;br /&gt;
	local qid, props = parseInput(frame, args[2], propertyID)&lt;br /&gt;
&lt;br /&gt;
	local linked = parseParam(args.linked, true)&lt;br /&gt;
	local lpre = (args.linkprefix or args.lp or &amp;quot;&amp;quot;):gsub(&#039;&amp;quot;&#039;, &#039;&#039;)&lt;br /&gt;
	local lpost = (args.linkpostfix or &amp;quot;&amp;quot;):gsub(&#039;&amp;quot;&#039;, &#039;&#039;)&lt;br /&gt;
	local pre = (args.prefix or &amp;quot;&amp;quot;):gsub(&#039;&amp;quot;&#039;, &#039;&#039;)&lt;br /&gt;
	local post = (args.postfix or &amp;quot;&amp;quot;):gsub(&#039;&amp;quot;&#039;, &#039;&#039;)&lt;br /&gt;
	local uabbr = parseParam(args.unitabbr or args.uabbr, false)&lt;br /&gt;
	local filter = (args.unit or &amp;quot;&amp;quot;):upper()&lt;br /&gt;
	local maxvals = tonumber(args.maxvals) or 0&lt;br /&gt;
	if filter == &amp;quot;&amp;quot; then filter = nil end&lt;br /&gt;
&lt;br /&gt;
	if qid then&lt;br /&gt;
		local out = {}&lt;br /&gt;
		-- Scan through the values of the property&lt;br /&gt;
		-- we want something like property is &amp;quot;pronunciation audio (P443)&amp;quot; in propertyID&lt;br /&gt;
		-- with a qualifier like &amp;quot;language of work or name (P407)&amp;quot; in qualID&lt;br /&gt;
		-- whose value has the required ID, like &amp;quot;British English (Q7979)&amp;quot;, in qval&lt;br /&gt;
		for k1, v1 in ipairs(props) do&lt;br /&gt;
			if v1.mainsnak.snaktype == &amp;quot;value&amp;quot; then&lt;br /&gt;
				-- check if it has the right qualifier&lt;br /&gt;
				local v1q = v1.qualifiers&lt;br /&gt;
				if v1q and v1q[qualID] then&lt;br /&gt;
					if onlysrc == false or sourced(v1) then&lt;br /&gt;
						-- if we&#039;ve got this far, we have a (sourced) claim with qualifiers&lt;br /&gt;
						-- so see if matches the required value&lt;br /&gt;
						-- We&#039;ll only deal with wikibase-items and strings for now&lt;br /&gt;
						if v1q[qualID][1].datatype == &amp;quot;wikibase-item&amp;quot; then&lt;br /&gt;
							if checkvalue(v1q[qualID][1].datavalue.value.id) then&lt;br /&gt;
								out[#out + 1] = rendersnak(v1, args, linked, lpre, lpost, pre, post, uabbr, filter)&lt;br /&gt;
							end&lt;br /&gt;
						elseif v1q[qualID][1].datatype == &amp;quot;string&amp;quot; then&lt;br /&gt;
							if checkvalue(v1q[qualID][1].datavalue.value) then&lt;br /&gt;
								out[#out + 1] = rendersnak(v1, args, linked, lpre, lpost, pre, post, uabbr, filter)&lt;br /&gt;
							end&lt;br /&gt;
						end&lt;br /&gt;
					end -- of check for sourced&lt;br /&gt;
				end -- of check for matching required value and has qualifiers&lt;br /&gt;
			else&lt;br /&gt;
				return nil&lt;br /&gt;
			end -- of check for string&lt;br /&gt;
			if maxvals &amp;gt; 0 and #out &amp;gt;= maxvals then break end&lt;br /&gt;
		end -- of loop through values of propertyID&lt;br /&gt;
		return assembleoutput(out, frame.args, qid, propertyID)&lt;br /&gt;
	else&lt;br /&gt;
		return props -- either local parameter or nothing&lt;br /&gt;
	end -- of test for success&lt;br /&gt;
	return nil&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
-- _location takes Q-id and follows P276 (location)&lt;br /&gt;
-- or P131 (located in the administrative territorial entity) or P706 (located on terrain feature)&lt;br /&gt;
-- from the initial item to higher level territories/locations until it reaches the highest.&lt;br /&gt;
-- An optional boolean, &#039;first&#039;, determines whether the first item is returned (default: false).&lt;br /&gt;
-- An optional boolean &#039;skip&#039; toggles the display to skip to the last item (default: false).&lt;br /&gt;
-- It returns a table containing the locations - linked where possible, except for the highest.&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
-- Dependencies: findLang(); labelOrId(); linkedItem&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
local _location = function(qid, first, skip)&lt;br /&gt;
	first = parseParam(first, false)&lt;br /&gt;
	skip = parseParam(skip, false)&lt;br /&gt;
	local locs = {&amp;quot;P276&amp;quot;, &amp;quot;P131&amp;quot;, &amp;quot;P706&amp;quot;}&lt;br /&gt;
	local out = {}&lt;br /&gt;
	local langcode = findLang():getCode()&lt;br /&gt;
	local finished = false&lt;br /&gt;
	local count = 0&lt;br /&gt;
	local prevqid = &amp;quot;Q0&amp;quot;&lt;br /&gt;
	repeat&lt;br /&gt;
		local prop&lt;br /&gt;
		for i1, v1 in ipairs(locs) do&lt;br /&gt;
			local proptbl = mw.wikibase.getBestStatements(qid, v1)&lt;br /&gt;
			if #proptbl &amp;gt; 1 then&lt;br /&gt;
				-- there is more than one higher location&lt;br /&gt;
				local prevP131, prevP131id&lt;br /&gt;
				if prevqid ~= &amp;quot;Q0&amp;quot; then&lt;br /&gt;
					prevP131 = mw.wikibase.getBestStatements(prevqid, &amp;quot;P131&amp;quot;)[1]&lt;br /&gt;
					prevP131id = prevP131&lt;br /&gt;
					and prevP131.mainsnak.datavalue&lt;br /&gt;
					and prevP131.mainsnak.datavalue.value.id&lt;br /&gt;
				end&lt;br /&gt;
				for i2, v2 in ipairs(proptbl) do&lt;br /&gt;
					local parttbl = v2.qualifiers and v2.qualifiers.P518&lt;br /&gt;
					if parttbl then&lt;br /&gt;
						-- this higher location has qualifier &#039;applies to part&#039; (P518)&lt;br /&gt;
						for i3, v3 in ipairs(parttbl) do&lt;br /&gt;
							if v3.snaktype == &amp;quot;value&amp;quot; and v3.datavalue.value.id == prevqid then&lt;br /&gt;
								-- it has a value equal to the previous location&lt;br /&gt;
								prop = proptbl[i2]&lt;br /&gt;
								break&lt;br /&gt;
							end -- of test for matching last location&lt;br /&gt;
						end -- of loop through values of &#039;applies to part&#039;&lt;br /&gt;
					else&lt;br /&gt;
						-- there&#039;s no qualifier &#039;applies to part&#039; (P518)&lt;br /&gt;
						-- so check if the previous location had a P131 that matches this alternate&lt;br /&gt;
						if qid == prevP131id then&lt;br /&gt;
								prop = proptbl[i2]&lt;br /&gt;
								break&lt;br /&gt;
						end -- of test for matching previous P131&lt;br /&gt;
					end&lt;br /&gt;
				end -- of loop through parent locations&lt;br /&gt;
				-- fallback to second value if match not found&lt;br /&gt;
				prop = prop or proptbl[2]&lt;br /&gt;
			elseif #proptbl &amp;gt; 0 then&lt;br /&gt;
				prop = proptbl[1]&lt;br /&gt;
			end&lt;br /&gt;
			if prop then break end&lt;br /&gt;
		end&lt;br /&gt;
&lt;br /&gt;
		-- check if it&#039;s an instance of (P31) a country (Q6256) or sovereign state (Q3624078)&lt;br /&gt;
		-- and terminate the chain if it is&lt;br /&gt;
		local inst = mw.wikibase.getAllStatements(qid, &amp;quot;P31&amp;quot;)&lt;br /&gt;
		if #inst &amp;gt; 0 then&lt;br /&gt;
			for k, v in ipairs(inst) do&lt;br /&gt;
				local instid = v.mainsnak.datavalue and v.mainsnak.datavalue.value.id&lt;br /&gt;
				-- stop if it&#039;s a country (or a country within the United Kingdom if skip is true)&lt;br /&gt;
				if instid == &amp;quot;Q6256&amp;quot; or instid == &amp;quot;Q3624078&amp;quot; or (skip and instid == &amp;quot;Q3336843&amp;quot;) then&lt;br /&gt;
					prop = nil -- this will ensure this is treated as top-level location&lt;br /&gt;
					break&lt;br /&gt;
				end&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
&lt;br /&gt;
		-- get the name of this location and update qid to point to the parent location&lt;br /&gt;
		if prop and prop.mainsnak.datavalue then&lt;br /&gt;
			if not skip or count == 0 then&lt;br /&gt;
				local args = { lprefix = &amp;quot;:&amp;quot; }&lt;br /&gt;
				out[#out+1] = linkedItem(qid, args) -- get a linked value if we can&lt;br /&gt;
			end&lt;br /&gt;
			qid, prevqid = prop.mainsnak.datavalue.value.id, qid&lt;br /&gt;
		else&lt;br /&gt;
			-- This is top-level location, so get short name except when this is the first item&lt;br /&gt;
			-- Use full label if there&#039;s no short name or this is the first item&lt;br /&gt;
			local prop1813 = mw.wikibase.getAllStatements(qid, &amp;quot;P1813&amp;quot;)&lt;br /&gt;
			-- if there&#039;s a short name and this isn&#039;t the only item&lt;br /&gt;
			if prop1813[1] and (#out &amp;gt; 0)then&lt;br /&gt;
				local shortname&lt;br /&gt;
				-- short name is monolingual text, so look for match to the local language&lt;br /&gt;
				-- choose the shortest &#039;short name&#039; in that language&lt;br /&gt;
				for k, v in pairs(prop1813) do&lt;br /&gt;
					if v.mainsnak.datavalue.value.language == langcode then&lt;br /&gt;
						local name = v.mainsnak.datavalue.value.text&lt;br /&gt;
						if (not shortname) or (#name &amp;lt; #shortname) then&lt;br /&gt;
							shortname = name&lt;br /&gt;
						end&lt;br /&gt;
					end&lt;br /&gt;
				end&lt;br /&gt;
				-- add the shortname if one is found, fallback to the label&lt;br /&gt;
				-- but skip it if it&#039;s &amp;quot;USA&amp;quot;&lt;br /&gt;
				if shortname ~= &amp;quot;USA&amp;quot; then&lt;br /&gt;
					out[#out+1] = shortname or labelOrId(qid)&lt;br /&gt;
				else&lt;br /&gt;
					if skip then out[#out+1] = &amp;quot;US&amp;quot; end&lt;br /&gt;
				end&lt;br /&gt;
			else&lt;br /&gt;
				-- no shortname, so just add the label&lt;br /&gt;
				local loc = labelOrId(qid)&lt;br /&gt;
				-- exceptions go here:&lt;br /&gt;
				if loc == &amp;quot;United States of America&amp;quot; then&lt;br /&gt;
					out[#out+1] = &amp;quot;United States&amp;quot;&lt;br /&gt;
				else&lt;br /&gt;
					out[#out+1] = loc&lt;br /&gt;
				end&lt;br /&gt;
			end&lt;br /&gt;
			finished = true&lt;br /&gt;
		end&lt;br /&gt;
		count = count + 1&lt;br /&gt;
	until finished or count &amp;gt;= 10 -- limit to 10 levels to avoid infinite loops&lt;br /&gt;
&lt;br /&gt;
	-- remove the first location if not required&lt;br /&gt;
	if not first then table.remove(out, 1) end&lt;br /&gt;
&lt;br /&gt;
	-- we might have duplicate text for consecutive locations, so remove them&lt;br /&gt;
	if #out &amp;gt; 2 then&lt;br /&gt;
		local plain = {}&lt;br /&gt;
		for i, v in ipairs(out) do&lt;br /&gt;
			-- strip any links&lt;br /&gt;
			plain[i] = v:gsub(&amp;quot;^%[%[[^|]*|&amp;quot;, &amp;quot;&amp;quot;):gsub(&amp;quot;]]$&amp;quot;, &amp;quot;&amp;quot;)&lt;br /&gt;
		end&lt;br /&gt;
		local idx = 2&lt;br /&gt;
		repeat&lt;br /&gt;
			if plain[idx] == plain[idx-1] then&lt;br /&gt;
				-- duplicate found&lt;br /&gt;
				local removeidx = 0&lt;br /&gt;
				if (plain[idx] ~= out[idx]) and (plain[idx-1] == out[idx-1]) then&lt;br /&gt;
					-- only second one is linked, so drop the first&lt;br /&gt;
					removeidx = idx - 1&lt;br /&gt;
				elseif (plain[idx] == out[idx]) and (plain[idx-1] ~= out[idx-1]) then&lt;br /&gt;
					-- only first one is linked, so drop the second&lt;br /&gt;
					removeidx = idx&lt;br /&gt;
				else&lt;br /&gt;
					-- pick one&lt;br /&gt;
					removeidx = idx - (os.time()%2)&lt;br /&gt;
				end&lt;br /&gt;
				table.remove(out, removeidx)&lt;br /&gt;
				table.remove(plain, removeidx)&lt;br /&gt;
			else&lt;br /&gt;
				idx = idx +1&lt;br /&gt;
			end&lt;br /&gt;
		until idx &amp;gt;= #out&lt;br /&gt;
	end&lt;br /&gt;
	return out&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
-- _getsumofparts scans the property &#039;has part&#039; (P527) for values matching a list.&lt;br /&gt;
-- The list (args.vlist) consists of a string of Qids separated by spaces or any usual punctuation.&lt;br /&gt;
-- If the matched values have a qualifer &#039;quantity&#039; (P1114), those quantites are summed.&lt;br /&gt;
-- The sum is returned as a number (i.e. 0 if none)&lt;br /&gt;
-- a table of arguments is supplied implementing the usual parameters.&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
-- Dependencies: setRanks; parseParam; parseInput; sourced; assembleoutput;&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
local _getsumofparts = function(args)&lt;br /&gt;
	local vallist = (args.vlist or &amp;quot;&amp;quot;):upper()&lt;br /&gt;
	if vallist == &amp;quot;&amp;quot; then return end&lt;br /&gt;
	args.reqranks = setRanks(args.rank)&lt;br /&gt;
	local f = {}&lt;br /&gt;
	f.args = args&lt;br /&gt;
	local qid, props = parseInput(f, &amp;quot;&amp;quot;, &amp;quot;P527&amp;quot;)&lt;br /&gt;
	if not qid then return 0 end&lt;br /&gt;
	local onlysrc = parseParam(args.onlysourced or args.osd, true)&lt;br /&gt;
	local sum = 0&lt;br /&gt;
	for k1, v1 in ipairs(props) do&lt;br /&gt;
		if (onlysrc == false or sourced(v1))&lt;br /&gt;
			and v1.mainsnak.snaktype == &amp;quot;value&amp;quot;&lt;br /&gt;
			and v1.mainsnak.datavalue.type == &amp;quot;wikibase-entityid&amp;quot;&lt;br /&gt;
			and vallist:match( v1.mainsnak.datavalue.value.id )&lt;br /&gt;
			and v1.qualifiers&lt;br /&gt;
			then&lt;br /&gt;
			local quals = v1.qualifiers[&amp;quot;P1114&amp;quot;]&lt;br /&gt;
			if quals then&lt;br /&gt;
				for k2, v2 in ipairs(quals) do&lt;br /&gt;
					sum = sum + v2.datavalue.value.amount&lt;br /&gt;
				end&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	return sum&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
-- Public functions&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
-- _getValue makes the functionality of getValue available to other modules&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
-- Dependencies: setRanks; parseInput; propertyvalueandquals; assembleoutput; parseParam; sourced;&lt;br /&gt;
-- labelOrId; i18n.latestdatequalifier; format_Date; makeOrdinal; roundto; decimalPrecision; decimalToDMS;&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
p._getValue = function(args)&lt;br /&gt;
	-- parameter sets for commonly used groups of parameters&lt;br /&gt;
	local paraset = tonumber(args.ps or args.parameterset or 0)&lt;br /&gt;
	if paraset == 1 then&lt;br /&gt;
		-- a common setting, not usable in infoboxes because the 2018 RFC requires sources&lt;br /&gt;
		args.rank = &amp;quot;best&amp;quot;&lt;br /&gt;
		args.fetchwikidata = &amp;quot;ALL&amp;quot;&lt;br /&gt;
		args.onlysourced = &amp;quot;no&amp;quot;&lt;br /&gt;
		args.noicon = &amp;quot;true&amp;quot;&lt;br /&gt;
	elseif paraset == 2 then&lt;br /&gt;
		-- equivalent to raw, not usable in infoboxes because the 2018 RFC requires sources&lt;br /&gt;
		args.rank = &amp;quot;best&amp;quot;&lt;br /&gt;
		args.fetchwikidata = &amp;quot;ALL&amp;quot;&lt;br /&gt;
		args.onlysourced = &amp;quot;no&amp;quot;&lt;br /&gt;
		args.noicon = &amp;quot;true&amp;quot;&lt;br /&gt;
		args.linked = &amp;quot;no&amp;quot;&lt;br /&gt;
		args.pd = &amp;quot;true&amp;quot;&lt;br /&gt;
	elseif paraset == 3 then&lt;br /&gt;
		-- parameterset 1, but usable in infoboxes because the 2018 RFC requires sources&lt;br /&gt;
		args.rank = &amp;quot;best&amp;quot;&lt;br /&gt;
		args.fetchwikidata = &amp;quot;ALL&amp;quot;&lt;br /&gt;
		args.onlysourced = &amp;quot;yes&amp;quot;&lt;br /&gt;
		args.noicon = &amp;quot;true&amp;quot;&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- implement eid parameter&lt;br /&gt;
	local eid = args.eid&lt;br /&gt;
	if eid == &amp;quot;&amp;quot; then&lt;br /&gt;
		return nil&lt;br /&gt;
	elseif eid then&lt;br /&gt;
		args.qid = eid&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	local propertyID = mw.text.trim(args[1] or &amp;quot;&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
	args.reqranks = setRanks(args.rank)&lt;br /&gt;
&lt;br /&gt;
	-- replacetext (rt) is a string that is returned instead of any non-empty Wikidata value&lt;br /&gt;
	-- this is useful for tracking and debugging, so we set fetchwikidata=ALL to fill the whitelist&lt;br /&gt;
	local replacetext = mw.text.trim(args.rt or args.replacetext or &amp;quot;&amp;quot;)&lt;br /&gt;
	if replacetext ~= &amp;quot;&amp;quot; then&lt;br /&gt;
		args.fetchwikidata = &amp;quot;ALL&amp;quot;&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	local f = {}&lt;br /&gt;
	f.args = args&lt;br /&gt;
	local entityid, props = parseInput(f, f.args[2], propertyID)&lt;br /&gt;
&lt;br /&gt;
	if not entityid then&lt;br /&gt;
		return props -- either the input parameter or nothing&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- qual is a string containing the property ID of the qualifier(s) to be returned&lt;br /&gt;
	-- if qual == &amp;quot;ALL&amp;quot; then all qualifiers returned&lt;br /&gt;
	-- if qual == &amp;quot;DATES&amp;quot; then qualifiers P580 (start time) and P582 (end time) returned&lt;br /&gt;
	-- if nothing or an empty string is passed set it nil -&amp;gt; no qualifiers returned&lt;br /&gt;
	local qualID = mw.text.trim(args.qual or &amp;quot;&amp;quot;):upper()&lt;br /&gt;
	if qualID == &amp;quot;&amp;quot; then qualID = nil end&lt;br /&gt;
&lt;br /&gt;
	-- set a language object and code in the args table&lt;br /&gt;
	args.langobj = findLang(args.lang)&lt;br /&gt;
	args.lang = args.langobj.code&lt;br /&gt;
&lt;br /&gt;
	-- table &#039;out&#039; stores the return value(s):&lt;br /&gt;
	local out = propertyvalueandquals(props, args, qualID)&lt;br /&gt;
&lt;br /&gt;
	-- format the table of values and return it as a string:&lt;br /&gt;
	return assembleoutput(out, args, entityid, propertyID)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
-- getValue is used to get the value(s) of a property&lt;br /&gt;
-- The property ID is passed as the first unnamed parameter and is required.&lt;br /&gt;
-- A locally supplied parameter may optionaly be supplied as the second unnamed parameter.&lt;br /&gt;
-- The function will now also return qualifiers if parameter qual is supplied&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
-- Dependencies: _getValue; setRanks; parseInput; propertyvalueandquals; assembleoutput; parseParam; sourced;&lt;br /&gt;
-- labelOrId; i18n.latestdatequalifier; format_Date; makeOrdinal; roundto; decimalPrecision; decimalToDMS;&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
p.getValue = function(frame)&lt;br /&gt;
	local args= frame.args&lt;br /&gt;
	if not args[1] then&lt;br /&gt;
		args = frame:getParent().args&lt;br /&gt;
		if not args[1] then return i18n.errors[&amp;quot;No property supplied&amp;quot;] end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	return p._getValue(args)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
-- getPreferredValue is used to get a value,&lt;br /&gt;
-- (or a comma separated list of them if multiple values exist).&lt;br /&gt;
-- If preferred ranks are set, it will return those values, otherwise values with normal ranks&lt;br /&gt;
-- now redundant to getValue with |rank=best&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
-- Dependencies: p.getValue; setRanks; parseInput; propertyvalueandquals; assembleoutput;&lt;br /&gt;
-- parseParam; sourced; labelOrId; i18n.latestdatequalifier; format_Date;&lt;br /&gt;
-- makeOrdinal; roundto; decimalPrecision; decimalToDMS;&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
p.getPreferredValue = function(frame)&lt;br /&gt;
	frame.args.rank = &amp;quot;best&amp;quot;&lt;br /&gt;
	return p.getValue(frame)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
-- getCoords is used to get coordinates for display in an infobox&lt;br /&gt;
-- whitelist and blacklist are implemented&lt;br /&gt;
-- optional &#039;display&#039; parameter is allowed, defaults to nil - was &amp;quot;inline, title&amp;quot;&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
-- Dependencies: setRanks(); parseInput(); decimalPrecision();&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
p.getCoords = function(frame)&lt;br /&gt;
	local propertyID = &amp;quot;P625&amp;quot;&lt;br /&gt;
&lt;br /&gt;
	-- if there is a &#039;display&#039; parameter supplied, use it&lt;br /&gt;
	-- otherwise default to nothing&lt;br /&gt;
	local disp = frame.args.display or &amp;quot;&amp;quot;&lt;br /&gt;
	if disp == &amp;quot;&amp;quot; then&lt;br /&gt;
		disp = nil -- default to not supplying display parameter, was &amp;quot;inline, title&amp;quot;&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- there may be a format parameter to switch from deg/min/sec to decimal degrees&lt;br /&gt;
	-- default is deg/min/sec&lt;br /&gt;
	-- decimal degrees needs |format = dec&lt;br /&gt;
	local form = (frame.args.format or &amp;quot;&amp;quot;):lower():sub(1,3)&lt;br /&gt;
	if form ~= &amp;quot;dec&amp;quot; then&lt;br /&gt;
		form = &amp;quot;dms&amp;quot;&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- just deal with best values&lt;br /&gt;
	frame.args.reqranks = setRanks(&amp;quot;best&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
	local qid, props = parseInput(frame, frame.args[1], propertyID)&lt;br /&gt;
	if not qid then&lt;br /&gt;
		return props -- either local parameter or nothing&lt;br /&gt;
	else&lt;br /&gt;
		local dv = props[1].mainsnak.datavalue.value&lt;br /&gt;
		local lat, long, prec = dv.latitude, dv.longitude, dv.precision&lt;br /&gt;
		lat = decimalPrecision(lat, prec)&lt;br /&gt;
		long = decimalPrecision(long, prec)&lt;br /&gt;
		local lat_long = { lat, long }&lt;br /&gt;
		lat_long[&amp;quot;display&amp;quot;] = disp&lt;br /&gt;
		lat_long[&amp;quot;format&amp;quot;] = form&lt;br /&gt;
		-- invoke template Coord with the values stored in the table&lt;br /&gt;
		return frame:expandTemplate{title = &#039;coord&#039;, args = lat_long}&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
-- getQualifierValue is used to get a formatted value of a qualifier&lt;br /&gt;
--&lt;br /&gt;
-- The call needs:	a property (the unnamed parameter or 1=)&lt;br /&gt;
-- 					a target value for that property (pval=)&lt;br /&gt;
--					a qualifier for that target value (qual=)&lt;br /&gt;
-- The usual whitelisting and blacklisting of the property is implemented&lt;br /&gt;
-- The boolean onlysourced= parameter can be set to return nothing&lt;br /&gt;
-- when the property is unsourced (or only sourced to Wikipedia)&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
-- Dependencies: parseParam(); setRanks(); parseInput(); sourced();&lt;br /&gt;
-- propertyvalueandquals(); assembleoutput();&lt;br /&gt;
-- labelOrId(); i18n.latestdatequalifier(); format_Date();&lt;br /&gt;
-- findLang(); makeOrdinal(); roundto(); decimalPrecision(); decimalToDMS();&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
p.getQualifierValue = function(frame)&lt;br /&gt;
&lt;br /&gt;
	-- The property ID that will have a qualifier is the first unnamed parameter&lt;br /&gt;
	local propertyID = mw.text.trim(frame.args[1] or &amp;quot;&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
	-- The value of the property we want to match whose qualifier value is to be returned&lt;br /&gt;
	-- is passed in named parameter |pval=&lt;br /&gt;
	local propvalue = frame.args.pval&lt;br /&gt;
&lt;br /&gt;
	-- The property ID of the qualifier&lt;br /&gt;
	-- whose value is to be returned is passed in named parameter |qual=&lt;br /&gt;
	local qualifierID = frame.args.qual&lt;br /&gt;
&lt;br /&gt;
	-- A filter can be set like this: filter=P642==Q22674854&lt;br /&gt;
	local filter, fprop, fval&lt;br /&gt;
	local ftable = mw.text.split(frame.args.filter or &amp;quot;&amp;quot;, &amp;quot;==&amp;quot;)&lt;br /&gt;
	if ftable[2] then&lt;br /&gt;
		fprop = mw.text.trim(ftable[1])&lt;br /&gt;
		fval = mw.text.trim(ftable[2])&lt;br /&gt;
		filter = true&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- onlysourced is a boolean passed to return qualifiers&lt;br /&gt;
	-- only when property values are sourced to something other than Wikipedia&lt;br /&gt;
	-- if nothing or an empty string is passed set it true&lt;br /&gt;
	-- if &amp;quot;false&amp;quot; or &amp;quot;no&amp;quot; or 0 is passed set it false&lt;br /&gt;
	local onlysrc = parseParam(frame.args.onlysourced or frame.args.osd, true)&lt;br /&gt;
&lt;br /&gt;
	-- set a language object and language code in the frame.args table&lt;br /&gt;
	frame.args.langobj = findLang(frame.args.lang)&lt;br /&gt;
	frame.args.lang = frame.args.langobj.code&lt;br /&gt;
&lt;br /&gt;
	-- set the requested ranks flags&lt;br /&gt;
	frame.args.reqranks = setRanks(frame.args.rank)&lt;br /&gt;
&lt;br /&gt;
	-- check for locally supplied parameter in second unnamed parameter&lt;br /&gt;
	-- success means no local parameter and the property exists&lt;br /&gt;
	local qid, props = parseInput(frame, frame.args[2], propertyID)&lt;br /&gt;
	if qid then&lt;br /&gt;
		local out = {}&lt;br /&gt;
		-- Scan through the values of the property&lt;br /&gt;
		-- we want something like property is P793, significant event (in propertyID)&lt;br /&gt;
		-- whose value is something like Q385378, construction (in propvalue)&lt;br /&gt;
		-- then we can return the value(s) of a qualifier such as P580, start time (in qualifierID)&lt;br /&gt;
		for k1, v1 in pairs(props) do&lt;br /&gt;
			if v1.mainsnak.snaktype == &amp;quot;value&amp;quot; and v1.mainsnak.datavalue.type == &amp;quot;wikibase-entityid&amp;quot; then&lt;br /&gt;
				-- It&#039;s a wiki-linked value, so check if it&#039;s the target (in propvalue) and if it has qualifiers&lt;br /&gt;
				if v1.mainsnak.datavalue.value.id == propvalue and v1.qualifiers then&lt;br /&gt;
					if onlysrc == false or sourced(v1) then&lt;br /&gt;
						-- if we&#039;ve got this far, we have a (sourced) claim with qualifiers&lt;br /&gt;
						-- which matches the target, so apply the filter and find the value(s) of the qualifier we want&lt;br /&gt;
						if not filter or (v1.qualifiers[fprop] and v1.qualifiers[fprop][1].datavalue.value.id == fval) then&lt;br /&gt;
							local quals = v1.qualifiers[qualifierID]&lt;br /&gt;
							if quals then&lt;br /&gt;
								-- can&#039;t reference qualifer, so set onlysourced = &amp;quot;no&amp;quot; (args are strings, not boolean)&lt;br /&gt;
								local qargs = frame.args&lt;br /&gt;
								qargs.onlysourced = &amp;quot;no&amp;quot;&lt;br /&gt;
								local vals = propertyvalueandquals(quals, qargs, qid)&lt;br /&gt;
								for k, v in ipairs(vals) do&lt;br /&gt;
									out[#out + 1] = v&lt;br /&gt;
								end&lt;br /&gt;
							end&lt;br /&gt;
						end&lt;br /&gt;
					end -- of check for sourced&lt;br /&gt;
				end -- of check for matching required value and has qualifiers&lt;br /&gt;
			end -- of check for wikibase entity&lt;br /&gt;
		end -- of loop through values of propertyID&lt;br /&gt;
		return assembleoutput(out, frame.args, qid, propertyID)&lt;br /&gt;
	else&lt;br /&gt;
		return props -- either local parameter or nothing&lt;br /&gt;
	end -- of test for success&lt;br /&gt;
	return nil&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
-- getSumOfParts scans the property &#039;has part&#039; (P527) for values matching a list.&lt;br /&gt;
-- The list is passed in parameter vlist.&lt;br /&gt;
-- It consists of a string of Qids separated by spaces or any usual punctuation.&lt;br /&gt;
-- If the matched values have a qualifier &#039;quantity&#039; (P1114), those quantities are summed.&lt;br /&gt;
-- The sum is returned as a number or nothing if zero.&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
-- Dependencies: _getsumofparts;&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
p.getSumOfParts = function(frame)&lt;br /&gt;
	local sum = _getsumofparts(frame.args)&lt;br /&gt;
	if sum == 0 then return end&lt;br /&gt;
	return sum&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
-- getValueByQual gets the value of a property which has a qualifier with a given entity value&lt;br /&gt;
-- The call needs:&lt;br /&gt;
--					a property ID (the unnamed parameter or 1=Pxxx)&lt;br /&gt;
--					the ID of a qualifier for that property (qualID=Pyyy)&lt;br /&gt;
--					either the Wikibase-entity ID of a value for that qualifier (qvalue=Qzzz)&lt;br /&gt;
--					or a string value for that qualifier (qvalue=abc123)&lt;br /&gt;
-- The usual whitelisting, blacklisting, onlysourced, etc. are implemented&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
-- Dependencies: _getvaluebyqual; parseParam; setRanks; parseInput; sourced;&lt;br /&gt;
-- assembleoutput;&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
p.getValueByQual = function(frame)&lt;br /&gt;
	local qualID = frame.args.qualID&lt;br /&gt;
	-- The Q-id of the value for the qualifier we want to match is in named parameter |qvalue=&lt;br /&gt;
	local qval = frame.args.qvalue or &amp;quot;&amp;quot;&lt;br /&gt;
	if qval == &amp;quot;&amp;quot; then return &amp;quot;no qualifier value supplied&amp;quot; end&lt;br /&gt;
	local function checkQID(id)&lt;br /&gt;
		return id == qval&lt;br /&gt;
	end&lt;br /&gt;
	return _getvaluebyqual(frame, qualID, checkQID)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
-- getValueByLang gets the value of a property which has a qualifier P407&lt;br /&gt;
-- (&amp;quot;language of work or name&amp;quot;) whose value has the given language code&lt;br /&gt;
-- The call needs:&lt;br /&gt;
--					a property ID (the unnamed parameter or 1=Pxxx)&lt;br /&gt;
--					the MediaWiki language code to match the language (lang=xx[-yy])&lt;br /&gt;
--					(if no code is supplied, it uses the default language)&lt;br /&gt;
-- The usual whitelisting, blacklisting, onlysourced, etc. are implemented&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
-- Dependencies: _getvaluebyqual; parseParam; setRanks; parseInput; sourced; assembleoutput;&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
p.getValueByLang = function(frame)&lt;br /&gt;
	-- The language code for the qualifier we want to match is in named parameter |lang=&lt;br /&gt;
	local langcode = findLang(frame.args.lang).code&lt;br /&gt;
	local function checkLanguage(id)&lt;br /&gt;
		-- id should represent a language like &amp;quot;British English (Q7979)&amp;quot;&lt;br /&gt;
		-- it should have string property &amp;quot;Wikimedia language code (P424)&amp;quot;&lt;br /&gt;
		-- qlcode will be a table:&lt;br /&gt;
		local qlcode = mw.wikibase.getBestStatements(id, &amp;quot;P424&amp;quot;)&lt;br /&gt;
		if (#qlcode &amp;gt; 0) and (qlcode[1].mainsnak.datavalue.value == langcode) then&lt;br /&gt;
			return true&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	return _getvaluebyqual(frame, &amp;quot;P407&amp;quot;, checkLanguage)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
-- getValueByRefSource gets the value of a property which has a reference &amp;quot;stated in&amp;quot; (P248)&lt;br /&gt;
-- whose value has the given entity-ID.&lt;br /&gt;
-- The call needs:&lt;br /&gt;
--					a property ID (the unnamed parameter or 1=Pxxx)&lt;br /&gt;
--					the entity ID of a value to match where the reference is stated in (match=Qzzz)&lt;br /&gt;
-- The usual whitelisting, blacklisting, onlysourced, etc. are implemented&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
-- Dependencies: parseParam; setRanks; parseInput; sourced; propertyvalueandquals assembleoutput;&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
p.getValueByRefSource = function(frame)&lt;br /&gt;
	-- The property ID that we want to check is the first unnamed parameter&lt;br /&gt;
	local propertyID = mw.text.trim(frame.args[1] or &amp;quot;&amp;quot;):upper()&lt;br /&gt;
	if propertyID == &amp;quot;&amp;quot; then return &amp;quot;no property supplied&amp;quot; end&lt;br /&gt;
&lt;br /&gt;
	-- The Q-id of the value we want to match is in named parameter |qvalue=&lt;br /&gt;
	local qval = (frame.args.match or &amp;quot;&amp;quot;):upper()&lt;br /&gt;
	if qval == &amp;quot;&amp;quot; then qval = &amp;quot;Q21540096&amp;quot; end&lt;br /&gt;
&lt;br /&gt;
	local unit = (frame.args.unit or &amp;quot;&amp;quot;):upper()&lt;br /&gt;
	if unit == &amp;quot;&amp;quot; then unit = &amp;quot;Q4917&amp;quot; end&lt;br /&gt;
&lt;br /&gt;
	local onlysrc = parseParam(frame.args.onlysourced or frame.args.osd, true)&lt;br /&gt;
&lt;br /&gt;
	-- set the requested ranks flags&lt;br /&gt;
	frame.args.reqranks = setRanks(frame.args.rank)&lt;br /&gt;
&lt;br /&gt;
	-- set a language object and code in the frame.args table&lt;br /&gt;
	frame.args.langobj = findLang(frame.args.lang)&lt;br /&gt;
	frame.args.lang = frame.args.langobj.code&lt;br /&gt;
&lt;br /&gt;
	local linked = parseParam(frame.args.linked, true)&lt;br /&gt;
&lt;br /&gt;
	local uabbr = parseParam(frame.args.uabbr or frame.args.unitabbr, false)&lt;br /&gt;
&lt;br /&gt;
	-- qid not nil means no local parameter and the property exists&lt;br /&gt;
	local qid, props = parseInput(frame, frame.args[2], propertyID)&lt;br /&gt;
&lt;br /&gt;
	if qid then&lt;br /&gt;
		local out = {}&lt;br /&gt;
		local mlt= {}&lt;br /&gt;
		for k1, v1 in ipairs(props) do&lt;br /&gt;
			if onlysrc == false or sourced(v1) then&lt;br /&gt;
				if v1.references then&lt;br /&gt;
					for k2, v2 in ipairs(v1.references) do&lt;br /&gt;
						if v2.snaks.P248 then&lt;br /&gt;
							for k3, v3 in ipairs(v2.snaks.P248) do&lt;br /&gt;
								if v3.datavalue.value.id == qval then&lt;br /&gt;
									out[#out+1], mlt[#out+1] = rendersnak(v1, frame.args, linked, &amp;quot;&amp;quot;, &amp;quot;&amp;quot;, &amp;quot;&amp;quot;, &amp;quot;&amp;quot;, uabbr, unit)&lt;br /&gt;
									if not mlt[#out] then&lt;br /&gt;
										-- we only need one match per property value&lt;br /&gt;
										-- unless datatype was monolingual text&lt;br /&gt;
										break&lt;br /&gt;
									end&lt;br /&gt;
								end -- of test for match&lt;br /&gt;
							end -- of loop through values &amp;quot;stated in&amp;quot;&lt;br /&gt;
						end -- of test that &amp;quot;stated in&amp;quot; exists&lt;br /&gt;
					end -- of loop through references&lt;br /&gt;
				end -- of test that references exist&lt;br /&gt;
			end -- of test for sourced&lt;br /&gt;
		end -- of loop through values of propertyID&lt;br /&gt;
		if #mlt &amp;gt; 0 then&lt;br /&gt;
			local langcode = frame.args.lang&lt;br /&gt;
			langcode = mw.text.split( langcode, &#039;-&#039;, true )[1]&lt;br /&gt;
			local fbtbl = mw.language.getFallbacksFor( langcode )&lt;br /&gt;
			table.insert( fbtbl, 1, langcode )&lt;br /&gt;
			local bestval = &amp;quot;&amp;quot;&lt;br /&gt;
			local found = false&lt;br /&gt;
			for idx1, lang1 in ipairs(fbtbl) do&lt;br /&gt;
				for idx2, lang2 in ipairs(mlt) do&lt;br /&gt;
					if (lang1 == lang2) and not found then&lt;br /&gt;
						bestval = out[idx2]&lt;br /&gt;
						found = true&lt;br /&gt;
						break&lt;br /&gt;
					end&lt;br /&gt;
				end -- loop through values of property&lt;br /&gt;
			end -- loop through fallback languages&lt;br /&gt;
			if found then&lt;br /&gt;
				-- replace output table with a table containing the best value&lt;br /&gt;
				out = { bestval }&lt;br /&gt;
			else&lt;br /&gt;
				-- more than one value and none of them on the list of fallback languages&lt;br /&gt;
				-- sod it, just give them the first one&lt;br /&gt;
				out = { out[1] }&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
		return assembleoutput(out, frame.args, qid, propertyID)&lt;br /&gt;
	else&lt;br /&gt;
		return props -- no property or local parameter supplied&lt;br /&gt;
	end -- of test for success&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
-- getPropertyIDs takes most of the usual parameters.&lt;br /&gt;
-- The usual whitelisting, blacklisting, onlysourced, etc. are implemented.&lt;br /&gt;
-- It returns the Entity-IDs (Qids) of the values of a property if it is a Wikibase-Entity.&lt;br /&gt;
-- Otherwise it returns nothing.&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
-- Dependencies: parseParam; setRanks; parseInput; sourced; propertyvalueandquals assembleoutput;&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
p._getPropertyIDs = function(args)&lt;br /&gt;
	args.reqranks = setRanks(args.rank)&lt;br /&gt;
	args.langobj = findLang(args.lang)&lt;br /&gt;
	args.lang = args.langobj.code&lt;br /&gt;
	-- change default for noicon to true&lt;br /&gt;
	args.noicon = tostring(parseParam(args.noicon or &amp;quot;&amp;quot;, true))&lt;br /&gt;
	local f = {}&lt;br /&gt;
	f.args = args&lt;br /&gt;
	local pid = mw.text.trim(args[1] or &amp;quot;&amp;quot;):upper()&lt;br /&gt;
&lt;br /&gt;
	-- get the qid and table of claims for the property, or nothing and the local value passed&lt;br /&gt;
	local qid, props = parseInput(f, args[2], pid)&lt;br /&gt;
	if not qid then return props end&lt;br /&gt;
	if not props[1] then return nil end&lt;br /&gt;
	local onlysrc = parseParam(args.onlysourced or args.osd, true)&lt;br /&gt;
	local maxvals = tonumber(args.maxvals) or 0&lt;br /&gt;
&lt;br /&gt;
	local out = {}&lt;br /&gt;
	for i, v in ipairs(props) do&lt;br /&gt;
		local snak = v.mainsnak&lt;br /&gt;
		if ( snak.datatype == &amp;quot;wikibase-item&amp;quot; )&lt;br /&gt;
			and ( v.rank and args.reqranks[v.rank:sub(1, 1)] )&lt;br /&gt;
			and ( snak.snaktype == &amp;quot;value&amp;quot; )&lt;br /&gt;
			and ( sourced(v) or not onlysrc )&lt;br /&gt;
			then&lt;br /&gt;
			out[#out+1] = snak.datavalue.value.id&lt;br /&gt;
		end&lt;br /&gt;
		if maxvals &amp;gt; 0 and #out &amp;gt;= maxvals then break end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	return assembleoutput(out, args, qid, pid)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
p.getPropertyIDs = function(frame)&lt;br /&gt;
	local args = frame.args&lt;br /&gt;
	return p._getPropertyIDs(args)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
-- getQualifierIDs takes most of the usual parameters.&lt;br /&gt;
-- The usual whitelisting, blacklisting, onlysourced, etc. are implemented.&lt;br /&gt;
-- It takes a property-id as the first unnamed parameter, and an optional parameter qlist&lt;br /&gt;
-- which is a list of qualifier property-ids to search for (default is &amp;quot;ALL&amp;quot;)&lt;br /&gt;
-- It returns the Entity-IDs (Qids) of the values of a property if it is a Wikibase-Entity.&lt;br /&gt;
-- Otherwise it returns nothing.&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
-- Dependencies: parseParam; setRanks; parseInput; sourced; propertyvalueandquals assembleoutput;&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
p.getQualifierIDs = function(frame)&lt;br /&gt;
	local args = frame.args&lt;br /&gt;
	args.reqranks = setRanks(args.rank)&lt;br /&gt;
	args.langobj = findLang(args.lang)&lt;br /&gt;
	args.lang = args.langobj.code&lt;br /&gt;
	-- change default for noicon to true&lt;br /&gt;
	args.noicon = tostring(parseParam(args.noicon or &amp;quot;&amp;quot;, true))&lt;br /&gt;
	local f = {}&lt;br /&gt;
	f.args = args&lt;br /&gt;
	local pid = mw.text.trim(args[1] or &amp;quot;&amp;quot;):upper()&lt;br /&gt;
&lt;br /&gt;
	-- get the qid and table of claims for the property, or nothing and the local value passed&lt;br /&gt;
	local qid, props = parseInput(f, args[2], pid)&lt;br /&gt;
	if not qid then return props end&lt;br /&gt;
	if not props[1] then return nil end&lt;br /&gt;
	-- get the other parameters&lt;br /&gt;
	local onlysrc = parseParam(args.onlysourced or args.osd, true)&lt;br /&gt;
	local maxvals = tonumber(args.maxvals) or 0&lt;br /&gt;
	local qlist = args.qlist or &amp;quot;&amp;quot;&lt;br /&gt;
	if qlist == &amp;quot;&amp;quot; then qlist = &amp;quot;ALL&amp;quot; end&lt;br /&gt;
	qlist = qlist:gsub(&amp;quot;[%p%s]+&amp;quot;, &amp;quot; &amp;quot;) .. &amp;quot; &amp;quot;&lt;br /&gt;
&lt;br /&gt;
	local out = {}&lt;br /&gt;
	for i, v in ipairs(props) do&lt;br /&gt;
		local snak = v.mainsnak&lt;br /&gt;
		if ( v.rank and args.reqranks[v.rank:sub(1, 1)] )&lt;br /&gt;
			and ( snak.snaktype == &amp;quot;value&amp;quot; )&lt;br /&gt;
			and ( sourced(v) or not onlysrc )&lt;br /&gt;
			then&lt;br /&gt;
			if v.qualifiers then&lt;br /&gt;
				for k1, v1 in pairs(v.qualifiers) do&lt;br /&gt;
					if qlist == &amp;quot;ALL &amp;quot; or qlist:match(k1 .. &amp;quot; &amp;quot;) then&lt;br /&gt;
						for i2, v2 in ipairs(v1) do&lt;br /&gt;
							if v2.datatype == &amp;quot;wikibase-item&amp;quot; and v2.snaktype == &amp;quot;value&amp;quot; then&lt;br /&gt;
								out[#out+1] = v2.datavalue.value.id&lt;br /&gt;
							end -- of test that id exists&lt;br /&gt;
						end -- of loop through qualifier values&lt;br /&gt;
					end -- of test for kq in qlist&lt;br /&gt;
				end -- of loop through qualifiers&lt;br /&gt;
			end -- of test for qualifiers&lt;br /&gt;
		end -- of test for rank value, sourced, and value exists&lt;br /&gt;
		if maxvals &amp;gt; 0 and #out &amp;gt;= maxvals then break end&lt;br /&gt;
	end -- of loop through property values&lt;br /&gt;
&lt;br /&gt;
	return assembleoutput(out, args, qid, pid)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
-- getPropOfProp takes two propertyIDs: prop1 and prop2 (as well as the usual parameters)&lt;br /&gt;
-- If the value(s) of prop1 are of type &amp;quot;wikibase-item&amp;quot; then it returns the value(s) of prop2&lt;br /&gt;
-- of each of those wikibase-items.&lt;br /&gt;
-- The usual whitelisting, blacklisting, onlysourced, etc. are implemented&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
-- Dependencies: parseParam; setRanks; parseInput; sourced; propertyvalueandquals assembleoutput;&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
p._getPropOfProp = function(args)&lt;br /&gt;
	-- parameter sets for commonly used groups of parameters&lt;br /&gt;
	local paraset = tonumber(args.ps or args.parameterset or 0)&lt;br /&gt;
	if paraset == 1 then&lt;br /&gt;
		-- a common setting&lt;br /&gt;
		args.rank = &amp;quot;best&amp;quot;&lt;br /&gt;
		args.fetchwikidata = &amp;quot;ALL&amp;quot;&lt;br /&gt;
		args.onlysourced = &amp;quot;no&amp;quot;&lt;br /&gt;
		args.noicon = &amp;quot;true&amp;quot;&lt;br /&gt;
	elseif paraset == 2 then&lt;br /&gt;
		-- equivalent to raw&lt;br /&gt;
		args.rank = &amp;quot;best&amp;quot;&lt;br /&gt;
		args.fetchwikidata = &amp;quot;ALL&amp;quot;&lt;br /&gt;
		args.onlysourced = &amp;quot;no&amp;quot;&lt;br /&gt;
		args.noicon = &amp;quot;true&amp;quot;&lt;br /&gt;
		args.linked = &amp;quot;no&amp;quot;&lt;br /&gt;
		args.pd = &amp;quot;true&amp;quot;&lt;br /&gt;
	elseif paraset == 3 then&lt;br /&gt;
		-- third set goes here&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	args.reqranks = setRanks(args.rank)&lt;br /&gt;
	args.langobj = findLang(args.lang)&lt;br /&gt;
	args.lang = args.langobj.code&lt;br /&gt;
	local pid1 = args.prop1 or args.pid1 or &amp;quot;&amp;quot;&lt;br /&gt;
	local pid2 = args.prop2 or args.pid2 or &amp;quot;&amp;quot;&lt;br /&gt;
	if pid1 == &amp;quot;&amp;quot; or pid2 == &amp;quot;&amp;quot; then return nil end&lt;br /&gt;
&lt;br /&gt;
	local f = {}&lt;br /&gt;
	f.args = args&lt;br /&gt;
	local qid1, statements1 = parseInput(f, args[1], pid1)&lt;br /&gt;
	-- parseInput nulls empty args[1] and returns args[1] if nothing on Wikidata&lt;br /&gt;
	if not qid1 then return statements1 end&lt;br /&gt;
	-- otherwise it returns the qid and a table for the statement&lt;br /&gt;
	local onlysrc = parseParam(args.onlysourced or args.osd, true)&lt;br /&gt;
	local maxvals = tonumber(args.maxvals) or 0&lt;br /&gt;
	local qualID = mw.text.trim(args.qual or &amp;quot;&amp;quot;):upper()&lt;br /&gt;
	if qualID == &amp;quot;&amp;quot; then qualID = nil end&lt;br /&gt;
	local out = {}&lt;br /&gt;
	for k, v in ipairs(statements1) do&lt;br /&gt;
		if not onlysrc or sourced(v) then&lt;br /&gt;
			local snak = v.mainsnak&lt;br /&gt;
			if snak.datatype == &amp;quot;wikibase-item&amp;quot; and snak.snaktype == &amp;quot;value&amp;quot; then&lt;br /&gt;
				local qid2 = snak.datavalue.value.id&lt;br /&gt;
				local statements2 = {}&lt;br /&gt;
				if args.reqranks.b then&lt;br /&gt;
					statements2 = mw.wikibase.getBestStatements(qid2, pid2)&lt;br /&gt;
				else&lt;br /&gt;
					statements2 = mw.wikibase.getAllStatements(qid2, pid2)&lt;br /&gt;
				end&lt;br /&gt;
				if statements2[1] then&lt;br /&gt;
					local out2 = propertyvalueandquals(statements2, args, qualID)&lt;br /&gt;
					out[#out+1] = assembleoutput(out2, args, qid2, pid2)&lt;br /&gt;
				end&lt;br /&gt;
			end -- of test for valid property1 value&lt;br /&gt;
		end -- of test for sourced&lt;br /&gt;
		if maxvals &amp;gt; 0 and #out &amp;gt;= maxvals then break end&lt;br /&gt;
	end -- of loop through values of property1&lt;br /&gt;
	return assembleoutput(out, args, qid1, pid1)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
p.getPropOfProp = function(frame)&lt;br /&gt;
	local args= frame.args&lt;br /&gt;
	if not args.prop1 and not args.pid1 then&lt;br /&gt;
		args = frame:getParent().args&lt;br /&gt;
		if not args.prop1 and not args.pid1 then return i18n.errors[&amp;quot;No property supplied&amp;quot;] end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	return p._getPropOfProp(args)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
-- getAwardCat takes most of the usual parameters. If the item has values of P166 (award received),&lt;br /&gt;
-- then it examines each of those awards for P2517 (category for recipients of this award).&lt;br /&gt;
-- If it exists, it returns the corresponding category,&lt;br /&gt;
-- with the item&#039;s P734 (family name) as sort key, or no sort key if there is no family name.&lt;br /&gt;
-- The sort key may be overridden by the parameter |sortkey (alias |sk).&lt;br /&gt;
-- The usual whitelisting, blacklisting, onlysourced, etc. are implemented&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
-- Dependencies: parseParam; setRanks; parseInput; sourced; propertyvalueandquals assembleoutput;&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
p.getAwardCat = function(frame)&lt;br /&gt;
	frame.args.reqranks = setRanks(frame.args.rank)&lt;br /&gt;
	frame.args.langobj = findLang(frame.args.lang)&lt;br /&gt;
	frame.args.lang = frame.args.langobj.code&lt;br /&gt;
	local args = frame.args&lt;br /&gt;
	args.sep = &amp;quot; &amp;quot;&lt;br /&gt;
	local pid1 = args.prop1 or &amp;quot;P166&amp;quot;&lt;br /&gt;
	local pid2 = args.prop2 or &amp;quot;P2517&amp;quot;&lt;br /&gt;
	if pid1 == &amp;quot;&amp;quot; or pid2 == &amp;quot;&amp;quot; then return nil end&lt;br /&gt;
	-- locally supplied value:&lt;br /&gt;
	local localval = mw.text.trim(args[1] or &amp;quot;&amp;quot;)&lt;br /&gt;
	local qid1, statements1 = parseInput(frame, localval, pid1)&lt;br /&gt;
	if not qid1 then return localval end&lt;br /&gt;
	-- linkprefix (strip quotes)&lt;br /&gt;
	local lp = (args.linkprefix or args.lp or &amp;quot;&amp;quot;):gsub(&#039;&amp;quot;&#039;, &#039;&#039;)&lt;br /&gt;
	-- sort key (strip quotes, hyphens and periods):&lt;br /&gt;
	local sk = (args.sortkey or args.sk or &amp;quot;&amp;quot;):gsub(&#039;[&amp;quot;-.]&#039;, &#039;&#039;)&lt;br /&gt;
	-- family name:&lt;br /&gt;
	local famname = &amp;quot;&amp;quot;&lt;br /&gt;
	if sk == &amp;quot;&amp;quot; then&lt;br /&gt;
		local p734 = mw.wikibase.getBestStatements(qid1, &amp;quot;P734&amp;quot;)[1]&lt;br /&gt;
		local p734id = p734 and p734.mainsnak.snaktype == &amp;quot;value&amp;quot; and p734.mainsnak.datavalue.value.id or &amp;quot;&amp;quot;&lt;br /&gt;
		famname = mw.wikibase.getSitelink(p734id) or &amp;quot;&amp;quot;&lt;br /&gt;
		-- strip namespace and disambigation&lt;br /&gt;
		local pos = famname:find(&amp;quot;:&amp;quot;) or 0&lt;br /&gt;
		famname = famname:sub(pos+1):gsub(&amp;quot;%s%(.+%)$&amp;quot;, &amp;quot;&amp;quot;)&lt;br /&gt;
		if famname == &amp;quot;&amp;quot; then&lt;br /&gt;
			local lbl = mw.wikibase.getLabel(p734id)&lt;br /&gt;
			famname = lbl and mw.text.nowiki(lbl) or &amp;quot;&amp;quot;&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	local onlysrc = parseParam(args.onlysourced or args.osd, true)&lt;br /&gt;
	local maxvals = tonumber(args.maxvals) or 0&lt;br /&gt;
	local qualID = mw.text.trim(args.qual or &amp;quot;&amp;quot;):upper()&lt;br /&gt;
	if qualID == &amp;quot;&amp;quot; then qualID = nil end&lt;br /&gt;
	local out = {}&lt;br /&gt;
	for k, v in ipairs(statements1) do&lt;br /&gt;
		if not onlysrc or sourced(v) then&lt;br /&gt;
			local snak = v.mainsnak&lt;br /&gt;
			if snak.datatype == &amp;quot;wikibase-item&amp;quot; and snak.snaktype == &amp;quot;value&amp;quot; then&lt;br /&gt;
				local qid2 = snak.datavalue.value.id&lt;br /&gt;
				local statements2 = {}&lt;br /&gt;
				if args.reqranks.b then&lt;br /&gt;
					statements2 = mw.wikibase.getBestStatements(qid2, pid2)&lt;br /&gt;
				else&lt;br /&gt;
					statements2 = mw.wikibase.getAllStatements(qid2, pid2)&lt;br /&gt;
				end&lt;br /&gt;
				if statements2[1] and statements2[1].mainsnak.snaktype == &amp;quot;value&amp;quot; then&lt;br /&gt;
					local qid3 = statements2[1].mainsnak.datavalue.value.id&lt;br /&gt;
					local sitelink = mw.wikibase.getSitelink(qid3)&lt;br /&gt;
					-- if there&#039;s no local sitelink, create the sitelink from English label&lt;br /&gt;
					if not sitelink then&lt;br /&gt;
						local lbl = mw.wikibase.getLabelByLang(qid3, &amp;quot;en&amp;quot;)&lt;br /&gt;
						if lbl then&lt;br /&gt;
							if lbl:sub(1,9) == &amp;quot;Category:&amp;quot; then&lt;br /&gt;
								sitelink = mw.text.nowiki(lbl)&lt;br /&gt;
							else&lt;br /&gt;
								sitelink = &amp;quot;Category:&amp;quot; .. mw.text.nowiki(lbl)&lt;br /&gt;
							end&lt;br /&gt;
						end&lt;br /&gt;
					end&lt;br /&gt;
					if sitelink then&lt;br /&gt;
						if sk ~= &amp;quot;&amp;quot; then&lt;br /&gt;
							out[#out+1] = &amp;quot;[[&amp;quot; .. lp .. sitelink .. &amp;quot;|&amp;quot; .. sk .. &amp;quot;]]&amp;quot;&lt;br /&gt;
						elseif famname ~= &amp;quot;&amp;quot; then&lt;br /&gt;
							out[#out+1] = &amp;quot;[[&amp;quot; .. lp .. sitelink .. &amp;quot;|&amp;quot; .. famname .. &amp;quot;]]&amp;quot;&lt;br /&gt;
						else&lt;br /&gt;
							out[#out+1] = &amp;quot;[[&amp;quot; .. lp .. sitelink .. &amp;quot;]]&amp;quot;&lt;br /&gt;
						end -- of check for sort keys&lt;br /&gt;
					end -- of test for sitelink&lt;br /&gt;
				end -- of test for category&lt;br /&gt;
			end -- of test for wikibase item has a value&lt;br /&gt;
		end -- of test for sourced&lt;br /&gt;
		if maxvals &amp;gt; 0 and #out &amp;gt;= maxvals then break end&lt;br /&gt;
	end -- of loop through values of property1&lt;br /&gt;
	return assembleoutput(out, args, qid1, pid1)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
-- getIntersectCat takes most of the usual parameters.&lt;br /&gt;
-- The usual whitelisting, blacklisting, onlysourced, etc. are implemented&lt;br /&gt;
-- It takes two properties, |prop1 and |prop2 (e.g. occupation and country of citizenship)&lt;br /&gt;
-- Each property&#039;s value is a wiki-base entity&lt;br /&gt;
-- For each value of the first parameter (ranks implemented) it fetches the value&#039;s main category&lt;br /&gt;
-- and then each value of the second parameter (possibly substituting a simpler description)&lt;br /&gt;
-- then it returns all of the categories representing the intersection of those properties,&lt;br /&gt;
-- (e.g. Category:Actors from Canada). A joining term may be supplied (e.g. |join=from).&lt;br /&gt;
-- The item&#039;s P734 (family name) is the sort key, or no sort key if there is no family name.&lt;br /&gt;
-- The sort key may be overridden by the parameter |sortkey (alias |sk).&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
-- Dependencies: parseParam; setRanks; parseInput; sourced; propertyvalueandquals assembleoutput;&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
p.getIntersectCat = function(frame)&lt;br /&gt;
	frame.args.reqranks = setRanks(frame.args.rank)&lt;br /&gt;
	frame.args.langobj = findLang(frame.args.lang)&lt;br /&gt;
	frame.args.lang = frame.args.langobj.code&lt;br /&gt;
	local args = frame.args&lt;br /&gt;
	args.sep = &amp;quot; &amp;quot;&lt;br /&gt;
	args.linked = &amp;quot;no&amp;quot;&lt;br /&gt;
	local pid1 = args.prop1 or &amp;quot;P106&amp;quot;&lt;br /&gt;
	local pid2 = args.prop2 or &amp;quot;P27&amp;quot;&lt;br /&gt;
	if pid1 == &amp;quot;&amp;quot; or pid2 == &amp;quot;&amp;quot; then return nil end&lt;br /&gt;
	local qid, statements1 = parseInput(frame, &amp;quot;&amp;quot;, pid1)&lt;br /&gt;
	if not qid then return nil end&lt;br /&gt;
	local qid, statements2 = parseInput(frame, &amp;quot;&amp;quot;, pid2)&lt;br /&gt;
	if not qid then return nil end&lt;br /&gt;
	-- topics like countries may have different names in categories from their label in Wikidata&lt;br /&gt;
	local subs_exists, subs = pcall(mw.loadData, &amp;quot;Module:WikidataIB/subs&amp;quot;)&lt;br /&gt;
	local join = args.join or &amp;quot;&amp;quot;&lt;br /&gt;
	local onlysrc = parseParam(args.onlysourced or args.osd, true)&lt;br /&gt;
	local maxvals = tonumber(args.maxvals) or 0&lt;br /&gt;
	-- linkprefix (strip quotes)&lt;br /&gt;
	local lp = (args.linkprefix or args.lp or &amp;quot;&amp;quot;):gsub(&#039;&amp;quot;&#039;, &#039;&#039;)&lt;br /&gt;
	-- sort key (strip quotes, hyphens and periods):&lt;br /&gt;
	local sk = (args.sortkey or args.sk or &amp;quot;&amp;quot;):gsub(&#039;[&amp;quot;-.]&#039;, &#039;&#039;)&lt;br /&gt;
	-- family name:&lt;br /&gt;
	local famname = &amp;quot;&amp;quot;&lt;br /&gt;
	if sk == &amp;quot;&amp;quot; then&lt;br /&gt;
		local p734 = mw.wikibase.getBestStatements(qid, &amp;quot;P734&amp;quot;)[1]&lt;br /&gt;
		local p734id = p734 and p734.mainsnak.snaktype == &amp;quot;value&amp;quot; and p734.mainsnak.datavalue.value.id or &amp;quot;&amp;quot;&lt;br /&gt;
		famname = mw.wikibase.getSitelink(p734id) or &amp;quot;&amp;quot;&lt;br /&gt;
		-- strip namespace and disambigation&lt;br /&gt;
		local pos = famname:find(&amp;quot;:&amp;quot;) or 0&lt;br /&gt;
		famname = famname:sub(pos+1):gsub(&amp;quot;%s%(.+%)$&amp;quot;, &amp;quot;&amp;quot;)&lt;br /&gt;
		if famname == &amp;quot;&amp;quot; then&lt;br /&gt;
			local lbl = mw.wikibase.getLabel(p734id)&lt;br /&gt;
			famname = lbl and mw.text.nowiki(lbl) or &amp;quot;&amp;quot;&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	local cat1 = {}&lt;br /&gt;
	for k, v in ipairs(statements1) do&lt;br /&gt;
		if not onlysrc or sourced(v) then&lt;br /&gt;
			-- get the ID representing the value of the property&lt;br /&gt;
			local pvalID = (v.mainsnak.snaktype == &amp;quot;value&amp;quot;) and v.mainsnak.datavalue.value.id&lt;br /&gt;
			if pvalID then&lt;br /&gt;
				-- get the topic&#039;s main category (P910) for that entity&lt;br /&gt;
				local p910 = mw.wikibase.getBestStatements(pvalID, &amp;quot;P910&amp;quot;)[1]&lt;br /&gt;
				if p910 and p910.mainsnak.snaktype == &amp;quot;value&amp;quot; then&lt;br /&gt;
					local tmcID = p910.mainsnak.datavalue.value.id&lt;br /&gt;
					-- use sitelink or the English label for the cat&lt;br /&gt;
					local cat = mw.wikibase.getSitelink(tmcID)&lt;br /&gt;
					if not cat then&lt;br /&gt;
						local lbl = mw.wikibase.getLabelByLang(tmcID, &amp;quot;en&amp;quot;)&lt;br /&gt;
						if lbl then&lt;br /&gt;
							if lbl:sub(1,9) == &amp;quot;Category:&amp;quot; then&lt;br /&gt;
								cat = mw.text.nowiki(lbl)&lt;br /&gt;
							else&lt;br /&gt;
								cat = &amp;quot;Category:&amp;quot; .. mw.text.nowiki(lbl)&lt;br /&gt;
							end&lt;br /&gt;
						end&lt;br /&gt;
					end&lt;br /&gt;
					cat1[#cat1+1] = cat&lt;br /&gt;
				end -- of test for topic&#039;s main category exists&lt;br /&gt;
			end -- of test for property has vaild value&lt;br /&gt;
		end -- of test for sourced&lt;br /&gt;
		if maxvals &amp;gt; 0 and #cat1 &amp;gt;= maxvals then break end&lt;br /&gt;
	end&lt;br /&gt;
	local cat2 = {}&lt;br /&gt;
	for k, v in ipairs(statements2) do&lt;br /&gt;
		if not onlysrc or sourced(v) then&lt;br /&gt;
			local cat = rendersnak(v, args)&lt;br /&gt;
			if subs[cat] then cat = subs[cat] end&lt;br /&gt;
			cat2[#cat2+1] = cat&lt;br /&gt;
		end&lt;br /&gt;
		if maxvals &amp;gt; 0 and #cat2 &amp;gt;= maxvals then break end&lt;br /&gt;
	end&lt;br /&gt;
	local out = {}&lt;br /&gt;
	for k1, v1 in ipairs(cat1) do&lt;br /&gt;
		for k2, v2 in ipairs(cat2) do&lt;br /&gt;
			if sk ~= &amp;quot;&amp;quot; then&lt;br /&gt;
				out[#out+1] = &amp;quot;[[&amp;quot; .. lp .. v1 .. &amp;quot; &amp;quot; .. join .. &amp;quot; &amp;quot; .. v2 .. &amp;quot;|&amp;quot; .. sk .. &amp;quot;]]&amp;quot;&lt;br /&gt;
			elseif famname ~= &amp;quot;&amp;quot; then&lt;br /&gt;
				out[#out+1] = &amp;quot;[[&amp;quot; .. lp .. v1 .. &amp;quot; &amp;quot; .. join .. &amp;quot; &amp;quot; .. v2 .. &amp;quot;|&amp;quot; .. famname .. &amp;quot;]]&amp;quot;&lt;br /&gt;
			else&lt;br /&gt;
				out[#out+1] = &amp;quot;[[&amp;quot; .. lp .. v1 .. &amp;quot; &amp;quot; .. join .. &amp;quot; &amp;quot; .. v2 .. &amp;quot;]]&amp;quot;&lt;br /&gt;
			end -- of check for sort keys&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	args.noicon = &amp;quot;true&amp;quot;&lt;br /&gt;
	return assembleoutput(out, args, qid, pid1)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
-- qualsToTable takes most of the usual parameters.&lt;br /&gt;
-- The usual whitelisting, blacklisting, onlysourced, etc. are implemented.&lt;br /&gt;
-- A qid may be given, and the first unnamed parameter is the property ID, which is of type wikibase item.&lt;br /&gt;
-- It takes a list of qualifier property IDs as |quals=&lt;br /&gt;
-- For a given qid and property, it creates the rows of an html table,&lt;br /&gt;
-- each row being a value of the property (optionally only if the property matches the value in |pval= )&lt;br /&gt;
-- each cell being the first value of the qualifier corresponding to the list in |quals&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
-- Dependencies: parseParam; setRanks; parseInput; sourced;&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
p.qualsToTable = function(frame)&lt;br /&gt;
	local args = frame.args&lt;br /&gt;
&lt;br /&gt;
	local quals = args.quals or &amp;quot;&amp;quot;&lt;br /&gt;
	if quals == &amp;quot;&amp;quot; then return &amp;quot;&amp;quot; end&lt;br /&gt;
&lt;br /&gt;
	args.reqranks = setRanks(args.rank)&lt;br /&gt;
&lt;br /&gt;
	local propertyID = mw.text.trim(args[1] or &amp;quot;&amp;quot;)&lt;br /&gt;
	local f = {}&lt;br /&gt;
	f.args = args&lt;br /&gt;
	local entityid, props = parseInput(f, &amp;quot;&amp;quot;, propertyID)&lt;br /&gt;
	if not entityid then return &amp;quot;&amp;quot; end&lt;br /&gt;
&lt;br /&gt;
	args.langobj = findLang(args.lang)&lt;br /&gt;
	args.lang = args.langobj.code&lt;br /&gt;
&lt;br /&gt;
	local pval = args.pval or &amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
	local qplist = mw.text.split(quals, &amp;quot;%p&amp;quot;) -- split at punctuation and make a sequential table&lt;br /&gt;
	for i, v in ipairs(qplist) do&lt;br /&gt;
		qplist[i] = mw.text.trim(v):upper() -- remove whitespace and capitalise&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	local col1 = args.firstcol or &amp;quot;&amp;quot;&lt;br /&gt;
	if col1 ~= &amp;quot;&amp;quot; then&lt;br /&gt;
		col1 = col1 .. &amp;quot;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&amp;quot;&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	local emptycell = args.emptycell or &amp;quot;&amp;amp;nbsp;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
	-- construct a 2-D array of qualifier values in qvals&lt;br /&gt;
	local qvals = {}&lt;br /&gt;
	for i, v in ipairs(props) do&lt;br /&gt;
		local skip = false&lt;br /&gt;
		if pval ~= &amp;quot;&amp;quot; then&lt;br /&gt;
			local pid = v.mainsnak.datavalue and v.mainsnak.datavalue.value.id&lt;br /&gt;
			if pid ~= pval then skip = true end&lt;br /&gt;
		end&lt;br /&gt;
		if not skip then&lt;br /&gt;
			local qval = {}&lt;br /&gt;
			local vqualifiers = v.qualifiers or {}&lt;br /&gt;
			-- go through list of wanted qualifier properties&lt;br /&gt;
			for i1, v1 in ipairs(qplist) do&lt;br /&gt;
				-- check for that property ID in the statement&#039;s qualifiers&lt;br /&gt;
				local qv, qtype&lt;br /&gt;
				if vqualifiers[v1] then&lt;br /&gt;
					qtype = vqualifiers[v1][1].datatype&lt;br /&gt;
					if qtype == &amp;quot;time&amp;quot; then&lt;br /&gt;
						if vqualifiers[v1][1].snaktype == &amp;quot;value&amp;quot; then&lt;br /&gt;
							qv = mw.wikibase.renderSnak(vqualifiers[v1][1])&lt;br /&gt;
							qv = frame:expandTemplate{title=&amp;quot;dts&amp;quot;, args={qv}}&lt;br /&gt;
						else&lt;br /&gt;
							qv = &amp;quot;?&amp;quot;&lt;br /&gt;
						end&lt;br /&gt;
					elseif qtype == &amp;quot;url&amp;quot; then&lt;br /&gt;
						if vqualifiers[v1][1].snaktype == &amp;quot;value&amp;quot; then&lt;br /&gt;
							qv = mw.wikibase.renderSnak(vqualifiers[v1][1])&lt;br /&gt;
							local display = mw.ustring.match( mw.uri.decode(qv, &amp;quot;WIKI&amp;quot;), &amp;quot;([%w ]+)$&amp;quot; )&lt;br /&gt;
							if display then&lt;br /&gt;
								qv = &amp;quot;[&amp;quot; .. qv .. &amp;quot; &amp;quot; .. display .. &amp;quot;]&amp;quot;&lt;br /&gt;
							end&lt;br /&gt;
						end&lt;br /&gt;
					else&lt;br /&gt;
						qv = mw.wikibase.formatValue(vqualifiers[v1][1])&lt;br /&gt;
					end&lt;br /&gt;
				end&lt;br /&gt;
				-- record either the value or a placeholder&lt;br /&gt;
				qval[i1] = qv or emptycell&lt;br /&gt;
			end -- of loop through list of qualifiers&lt;br /&gt;
			-- add the list of qualifier values as a &amp;quot;row&amp;quot; in the main list&lt;br /&gt;
			qvals[#qvals+1] = qval&lt;br /&gt;
		end&lt;br /&gt;
	end -- of for each value loop&lt;br /&gt;
&lt;br /&gt;
	local out = {}&lt;br /&gt;
	for i, v in ipairs(qvals) do&lt;br /&gt;
		out[i] = &amp;quot;&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;&amp;quot; .. col1 .. table.concat(qvals[i], &amp;quot;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&amp;quot;) .. &amp;quot;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&amp;quot;&lt;br /&gt;
	end&lt;br /&gt;
	return table.concat(out, &amp;quot;\n&amp;quot;)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
-- getGlobe takes an optional qid of a Wikidata entity passed as |qid=&lt;br /&gt;
-- otherwise it uses the linked item for the current page.&lt;br /&gt;
-- If returns the Qid of the globe used in P625 (coordinate location),&lt;br /&gt;
-- or nil if there isn&#039;t one.&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
-- Dependencies: none&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
p.getGlobe = function(frame)&lt;br /&gt;
	local qid = frame.args.qid or frame.args[1] or &amp;quot;&amp;quot;&lt;br /&gt;
	if qid == &amp;quot;&amp;quot; then qid = mw.wikibase.getEntityIdForCurrentPage() end&lt;br /&gt;
	local coords = mw.wikibase.getBestStatements(qid, &amp;quot;P625&amp;quot;)[1]&lt;br /&gt;
	local globeid&lt;br /&gt;
	if coords and coords.mainsnak.snaktype == &amp;quot;value&amp;quot; then&lt;br /&gt;
		globeid = coords.mainsnak.datavalue.value.globe:match(&amp;quot;(Q%d+)&amp;quot;)&lt;br /&gt;
	end&lt;br /&gt;
	return globeid&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
-- getCommonsLink takes an optional qid of a Wikidata entity passed as |qid=&lt;br /&gt;
-- It returns one of the following in order of preference:&lt;br /&gt;
-- the Commons sitelink of the linked Wikidata item;&lt;br /&gt;
-- the Commons sitelink of the topic&#039;s main category of the linked Wikidata item;&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
-- Dependencies: _getCommonslink(); _getSitelink(); parseParam()&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
p.getCommonsLink = function(frame)&lt;br /&gt;
	local oc = frame.args.onlycat or frame.args.onlycategories&lt;br /&gt;
	local fb = parseParam(frame.args.fallback or frame.args.fb, true)&lt;br /&gt;
	return _getCommonslink(frame.args.qid, oc, fb)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
-- getSitelink takes the qid of a Wikidata entity passed as |qid=&lt;br /&gt;
-- It takes an optional parameter |wiki= to determine which wiki is to be checked for a sitelink&lt;br /&gt;
-- If the parameter is blank, then it uses the local wiki.&lt;br /&gt;
-- If there is a sitelink to an article available, it returns the plain text link to the article&lt;br /&gt;
-- If there is no sitelink, it returns nil.&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
-- Dependencies: none&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
p.getSiteLink = function(frame)&lt;br /&gt;
	return _getSitelink(frame.args.qid, frame.args.wiki or mw.text.trim(frame.args[1] or &amp;quot;&amp;quot;))&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
-- getLink has the qid of a Wikidata entity passed as the first unnamed parameter or as |qid=&lt;br /&gt;
-- If there is a sitelink to an article on the local Wiki, it returns a link to the article&lt;br /&gt;
-- with the Wikidata label as the displayed text.&lt;br /&gt;
-- If there is no sitelink, it returns the label as plain text.&lt;br /&gt;
-- If there is no label in the local language, it displays the qid instead.&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
-- Dependencies: none&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
p.getLink = function(frame)&lt;br /&gt;
	local itemID = mw.text.trim(frame.args[1] or frame.args.qid or &amp;quot;&amp;quot;)&lt;br /&gt;
	if itemID == &amp;quot;&amp;quot; then return end&lt;br /&gt;
	local sitelink = mw.wikibase.getSitelink(itemID)&lt;br /&gt;
	local label = labelOrId(itemID)&lt;br /&gt;
	if sitelink then&lt;br /&gt;
		return &amp;quot;[[:&amp;quot; .. sitelink .. &amp;quot;|&amp;quot; .. label .. &amp;quot;]]&amp;quot;&lt;br /&gt;
	else&lt;br /&gt;
		return label&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
-- getLabel has the qid of a Wikidata entity passed as the first unnamed parameter or as |qid=&lt;br /&gt;
-- It returns the Wikidata label for the local language as plain text.&lt;br /&gt;
-- If there is no label in the local language, it displays the qid instead.&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
-- Dependencies: none&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
p.getLabel = function(frame)&lt;br /&gt;
	local itemID = mw.text.trim(frame.args[1] or frame.args.qid or &amp;quot;&amp;quot;)&lt;br /&gt;
	if itemID == &amp;quot;&amp;quot; then return end&lt;br /&gt;
	local lang = frame.args.lang or &amp;quot;&amp;quot;&lt;br /&gt;
	if lang == &amp;quot;&amp;quot; then lang = nil end&lt;br /&gt;
	local label = labelOrId(itemID, lang)&lt;br /&gt;
	return label&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
-- label has the qid of a Wikidata entity passed as the first unnamed parameter or as |qid=&lt;br /&gt;
-- if no qid is supplied, it uses the qid associated with the current page.&lt;br /&gt;
-- It returns the Wikidata label for the local language as plain text.&lt;br /&gt;
-- If there is no label in the local language, it returns nil.&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
-- Dependencies: none&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
p.label = function(frame)&lt;br /&gt;
	local qid = mw.text.trim(frame.args[1] or frame.args.qid or &amp;quot;&amp;quot;)&lt;br /&gt;
	if qid == &amp;quot;&amp;quot; then qid = mw.wikibase.getEntityIdForCurrentPage() end&lt;br /&gt;
	if not qid then return end&lt;br /&gt;
	local lang = frame.args.lang or &amp;quot;&amp;quot;&lt;br /&gt;
	if lang == &amp;quot;&amp;quot; then lang = nil end&lt;br /&gt;
	local label, success = labelOrId(qid, lang)&lt;br /&gt;
	if success then return label end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
-- getAT (Article Title)&lt;br /&gt;
-- has the qid of a Wikidata entity passed as the first unnamed parameter or as |qid=&lt;br /&gt;
-- If there is a sitelink to an article on the local Wiki, it returns the sitelink as plain text.&lt;br /&gt;
-- If there is no sitelink or qid supplied, it returns nothing.&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
-- Dependencies: none&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
p.getAT = function(frame)&lt;br /&gt;
	local itemID = mw.text.trim(frame.args[1] or frame.args.qid or &amp;quot;&amp;quot;)&lt;br /&gt;
	if itemID == &amp;quot;&amp;quot; then return end&lt;br /&gt;
	return mw.wikibase.getSitelink(itemID)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
-- getDescription has the qid of a Wikidata entity passed as |qid=&lt;br /&gt;
-- (it defaults to the associated qid of the current article if omitted)&lt;br /&gt;
-- and a local parameter passed as the first unnamed parameter.&lt;br /&gt;
-- Any local parameter passed (other than &amp;quot;Wikidata&amp;quot; or &amp;quot;none&amp;quot;) becomes the return value.&lt;br /&gt;
-- It returns the article description for the Wikidata entity if the local parameter is &amp;quot;Wikidata&amp;quot;.&lt;br /&gt;
-- Nothing is returned if the description doesn&#039;t exist or &amp;quot;none&amp;quot; is passed as the local parameter.&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
-- Dependencies: none&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
p.getDescription = function(frame)&lt;br /&gt;
	local desc = mw.text.trim(frame.args[1] or &amp;quot;&amp;quot;)&lt;br /&gt;
	local itemID = mw.text.trim(frame.args.qid or &amp;quot;&amp;quot;)&lt;br /&gt;
	if itemID == &amp;quot;&amp;quot; then itemID = nil end&lt;br /&gt;
	if desc:lower() == &#039;wikidata&#039; then&lt;br /&gt;
		return mw.wikibase.getDescription(itemID)&lt;br /&gt;
	elseif desc:lower() == &#039;none&#039; then&lt;br /&gt;
		return nil&lt;br /&gt;
	else&lt;br /&gt;
		return desc&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
-- getAliases has the qid of a Wikidata entity passed as |qid=&lt;br /&gt;
-- (it defaults to the associated qid of the current article if omitted)&lt;br /&gt;
-- and a local parameter passed as the first unnamed parameter.&lt;br /&gt;
-- It implements blacklisting and whitelisting with a field name of &amp;quot;alias&amp;quot; by default.&lt;br /&gt;
-- Any local parameter passed becomes the return value.&lt;br /&gt;
-- Otherwise it returns the aliases for the Wikidata entity with the usual list options.&lt;br /&gt;
-- Nothing is returned if the aliases do not exist.&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
-- Dependencies: findLang(); assembleoutput()&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
p.getAliases = function(frame)&lt;br /&gt;
	local args = frame.args&lt;br /&gt;
&lt;br /&gt;
	local fieldname = args.name or &amp;quot;&amp;quot;&lt;br /&gt;
	if fieldname == &amp;quot;&amp;quot; then fieldname = &amp;quot;alias&amp;quot; end&lt;br /&gt;
&lt;br /&gt;
	local blacklist = args.suppressfields or args.spf or &amp;quot;&amp;quot;&lt;br /&gt;
	if blacklist:find(fieldname) then return nil end&lt;br /&gt;
&lt;br /&gt;
	local localval = mw.text.trim(args[1] or &amp;quot;&amp;quot;)&lt;br /&gt;
	if localval ~= &amp;quot;&amp;quot; then return localval end&lt;br /&gt;
&lt;br /&gt;
	local whitelist = args.fetchwikidata or args.fwd or &amp;quot;&amp;quot;&lt;br /&gt;
	if whitelist == &amp;quot;&amp;quot; then whitelist = &amp;quot;NONE&amp;quot; end&lt;br /&gt;
	if not (whitelist == &#039;ALL&#039; or whitelist:find(fieldname)) then return nil end&lt;br /&gt;
&lt;br /&gt;
	local qid = args.qid or &amp;quot;&amp;quot;&lt;br /&gt;
	if qid == &amp;quot;&amp;quot; then qid = mw.wikibase.getEntityIdForCurrentPage() end&lt;br /&gt;
	if not qid or not mw.wikibase.entityExists(qid) then return nil end&lt;br /&gt;
&lt;br /&gt;
	local aliases = mw.wikibase.getEntity(qid).aliases&lt;br /&gt;
	if not aliases then return nil end&lt;br /&gt;
&lt;br /&gt;
	args.langobj = findLang(args.lang)&lt;br /&gt;
	local langcode = args.langobj.code&lt;br /&gt;
	args.lang = langcode&lt;br /&gt;
&lt;br /&gt;
	local out = {}&lt;br /&gt;
	for k1, v1 in pairs(aliases) do&lt;br /&gt;
		if v1[1].language == langcode then&lt;br /&gt;
			for k1, v2 in ipairs(v1) do&lt;br /&gt;
				out[#out+1] = v2.value&lt;br /&gt;
			end&lt;br /&gt;
			break&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	return assembleoutput(out, args, qid)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
-- pageId returns the page id (entity ID, Qnnn) of the current page&lt;br /&gt;
-- returns nothing if the page is not connected to Wikidata&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
-- Dependencies: none&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
p.pageId = function(frame)&lt;br /&gt;
	return mw.wikibase.getEntityIdForCurrentPage()&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
-- formatDate is a wrapper to export the private function format_Date&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
-- Dependencies: format_Date();&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
p.formatDate = function(frame)&lt;br /&gt;
	return format_Date(frame.args[1], frame.args.df, frame.args.bc)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
-- location is a wrapper to export the private function _location&lt;br /&gt;
-- it takes the entity-id as qid or the first unnamed parameter&lt;br /&gt;
-- optional boolean parameter first toggles the display of the first item&lt;br /&gt;
-- optional boolean parameter skip toggles the display to skip to the last item&lt;br /&gt;
-- parameter debug=&amp;lt;y/n&amp;gt; (default &#039;n&#039;) adds error msg if not a location&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
-- Dependencies: _location();&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
p.location = function(frame)&lt;br /&gt;
	local debug = (frame.args.debug or &amp;quot;&amp;quot;):sub(1, 1):lower()&lt;br /&gt;
	if debug == &amp;quot;&amp;quot; then debug = &amp;quot;n&amp;quot; end&lt;br /&gt;
	local qid = mw.text.trim(frame.args.qid or frame.args[1] or &amp;quot;&amp;quot;):upper()&lt;br /&gt;
	if qid == &amp;quot;&amp;quot; then qid=mw.wikibase.getEntityIdForCurrentPage() end&lt;br /&gt;
	if not qid then&lt;br /&gt;
		if debug ~= &amp;quot;n&amp;quot; then&lt;br /&gt;
			return i18n.errors[&amp;quot;entity-not-found&amp;quot;]&lt;br /&gt;
		else&lt;br /&gt;
			return nil&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	local first = mw.text.trim(frame.args.first or &amp;quot;&amp;quot;)&lt;br /&gt;
	local skip = mw.text.trim(frame.args.skip or &amp;quot;&amp;quot;)&lt;br /&gt;
	return table.concat( _location(qid, first, skip), &amp;quot;, &amp;quot; )&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
-- checkBlacklist implements a test to check whether a named field is allowed&lt;br /&gt;
-- returns true if the field is not blacklisted (i.e. allowed)&lt;br /&gt;
-- returns false if the field is blacklisted (i.e. disallowed)&lt;br /&gt;
-- {{#if:{{#invoke:WikidataIB |checkBlacklist |name=Joe |suppressfields=Dave; Joe; Fred}} | not blacklisted | blacklisted}}&lt;br /&gt;
-- displays &amp;quot;blacklisted&amp;quot;&lt;br /&gt;
-- {{#if:{{#invoke:WikidataIB |checkBlacklist |name=Jim |suppressfields=Dave; Joe; Fred}} | not blacklisted | blacklisted}}&lt;br /&gt;
-- displays &amp;quot;not blacklisted&amp;quot;&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
-- Dependencies: none&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
p.checkBlacklist = function(frame)&lt;br /&gt;
	local blacklist = frame.args.suppressfields or frame.args.spf or &amp;quot;&amp;quot;&lt;br /&gt;
	local fieldname = frame.args.name or &amp;quot;&amp;quot;&lt;br /&gt;
	if blacklist ~= &amp;quot;&amp;quot; and fieldname ~= &amp;quot;&amp;quot; then&lt;br /&gt;
		if blacklist:find(fieldname) then&lt;br /&gt;
			return false&lt;br /&gt;
		else&lt;br /&gt;
			return true&lt;br /&gt;
		end&lt;br /&gt;
	else&lt;br /&gt;
		-- one of the fields is missing: let&#039;s call that &amp;quot;not on the list&amp;quot;&lt;br /&gt;
		return true&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
-- emptyor returns nil if its first unnamed argument is just punctuation, whitespace or html tags&lt;br /&gt;
-- otherwise it returns the argument unchanged (including leading/trailing space).&lt;br /&gt;
-- If the argument may contain &amp;quot;=&amp;quot;, then it must be called explicitly:&lt;br /&gt;
-- |1=arg&lt;br /&gt;
-- (In that case, leading and trailing spaces are trimmed)&lt;br /&gt;
-- It finds use in infoboxes where it can replace tests like:&lt;br /&gt;
-- {{#if: {{#invoke:WikidatIB |getvalue |P99 |fwd=ALL}} | &amp;lt;span class=&amp;quot;xxx&amp;quot;&amp;gt;{{#invoke:WikidatIB |getvalue |P99 |fwd=ALL}}&amp;lt;/span&amp;gt; | }}&lt;br /&gt;
-- with a form that uses just a single call to Wikidata:&lt;br /&gt;
-- {{#invoke |WikidataIB |emptyor |1= &amp;lt;span class=&amp;quot;xxx&amp;quot;&amp;gt;{{#invoke:WikidataIB |getvalue |P99 |fwd=ALL}}&amp;lt;/span&amp;gt; }}&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
-- Dependencies: none&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
p.emptyor = function(frame)&lt;br /&gt;
	local s = frame.args[1] or &amp;quot;&amp;quot;&lt;br /&gt;
	if s == &amp;quot;&amp;quot; then return nil end&lt;br /&gt;
	local sx = s:gsub(&amp;quot;%s&amp;quot;, &amp;quot;&amp;quot;):gsub(&amp;quot;&amp;lt;[^&amp;gt;]*&amp;gt;&amp;quot;, &amp;quot;&amp;quot;):gsub(&amp;quot;%p&amp;quot;, &amp;quot;&amp;quot;)&lt;br /&gt;
	if sx == &amp;quot;&amp;quot; then&lt;br /&gt;
		return nil&lt;br /&gt;
	else&lt;br /&gt;
		return s&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
-- labelorid is a public function to expose the output of labelOrId()&lt;br /&gt;
-- Pass the Q-number as |qid= or as an unnamed parameter.&lt;br /&gt;
-- It returns the Wikidata label for that entity or the qid if no label exists.&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
-- Dependencies: labelOrId&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
p.labelorid = function(frame)&lt;br /&gt;
	return (labelOrId(frame.args.qid or frame.args[1]))&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
-- getLang returns the MediaWiki language code of the current content.&lt;br /&gt;
-- If optional parameter |style=full, it returns the language name.&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
-- Dependencies: none&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
p.getLang = function(frame)&lt;br /&gt;
	local style = (frame.args.style or &amp;quot;&amp;quot;):lower()&lt;br /&gt;
	local langcode = mw.language.getContentLanguage().code&lt;br /&gt;
	if style == &amp;quot;full&amp;quot; then&lt;br /&gt;
		return mw.language.fetchLanguageName( langcode )&lt;br /&gt;
	end&lt;br /&gt;
	return langcode&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
-- getItemLangCode takes a qid parameter (using the current page&#039;s qid if blank)&lt;br /&gt;
-- If the item for that qid has property country (P17) it looks at the first preferred value&lt;br /&gt;
-- If the country has an official language (P37), it looks at the first preferred value&lt;br /&gt;
-- If that official language has a language code (P424), it returns the first preferred value&lt;br /&gt;
-- Otherwise it returns nothing.&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
-- Dependencies: _getItemLangCode()&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
p.getItemLangCode = function(frame)&lt;br /&gt;
	return _getItemLangCode(frame.args.qid or frame.args[1])&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
-- findLanguage exports the local findLang() function&lt;br /&gt;
-- It takes an optional language code and returns, in order of preference:&lt;br /&gt;
-- the code if a known language;&lt;br /&gt;
-- the user&#039;s language, if set;&lt;br /&gt;
-- the server&#039;s content language.&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
-- Dependencies: findLang&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
p.findLanguage = function(frame)&lt;br /&gt;
	return findLang(frame.args.lang or frame.args[1]).code&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
-- getQid returns the qid, if supplied&lt;br /&gt;
-- failing that, the Wikidata entity ID of the &amp;quot;category&#039;s main topic (P301)&amp;quot;, if it exists&lt;br /&gt;
-- failing that, the Wikidata entity ID associated with the current page, if it exists&lt;br /&gt;
-- otherwise, nothing&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
-- Dependencies: none&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
p.getQid = function(frame)&lt;br /&gt;
	local qid = (frame.args.qid or &amp;quot;&amp;quot;):upper()&lt;br /&gt;
	-- check if a qid was passed; if so, return it:&lt;br /&gt;
	if qid ~= &amp;quot;&amp;quot; then return qid end&lt;br /&gt;
	-- check if there&#039;s a &amp;quot;category&#039;s main topic (P301)&amp;quot;:&lt;br /&gt;
	qid = mw.wikibase.getEntityIdForCurrentPage()&lt;br /&gt;
	if qid then&lt;br /&gt;
		local prop301 = mw.wikibase.getBestStatements(qid, &amp;quot;P301&amp;quot;)&lt;br /&gt;
		if prop301[1] then&lt;br /&gt;
			local mctid = prop301[1].mainsnak.datavalue.value.id&lt;br /&gt;
			if mctid then return mctid end&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	-- otherwise return the page qid (if any)&lt;br /&gt;
	return qid&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
-- followQid takes four optional parameters: qid, props, list and all.&lt;br /&gt;
-- If qid is not given, it uses the qid for the connected page&lt;br /&gt;
-- or returns nil if there isn&#039;t one.&lt;br /&gt;
-- props is a list of properties, separated by punctuation.&lt;br /&gt;
-- If props is given, the Wikidata item for the qid is examined for each property in turn.&lt;br /&gt;
-- If that property contains a value that is another Wikibase-item, that item&#039;s qid is returned,&lt;br /&gt;
-- and the search terminates, unless |all=y when all of the qids are returned, separated by spaces.&lt;br /&gt;
-- If |list= is set to a template, the qids are passed as arguments to the template.&lt;br /&gt;
-- If props is not given, the qid is returned.&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
-- Dependencies: parseParam()&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
p._followQid = function(args)&lt;br /&gt;
	local qid = (args.qid or &amp;quot;&amp;quot;):upper()&lt;br /&gt;
	local all = parseParam(args.all, false)&lt;br /&gt;
	local list = args.list or &amp;quot;&amp;quot;&lt;br /&gt;
	if list == &amp;quot;&amp;quot; then list = nil end&lt;br /&gt;
	if qid == &amp;quot;&amp;quot; then&lt;br /&gt;
		qid = mw.wikibase.getEntityIdForCurrentPage()&lt;br /&gt;
	end&lt;br /&gt;
	if not qid then return nil end&lt;br /&gt;
	local out = {}&lt;br /&gt;
	local props = (args.props or &amp;quot;&amp;quot;):upper()&lt;br /&gt;
	if props ~= &amp;quot;&amp;quot; then&lt;br /&gt;
		for p in mw.text.gsplit(props, &amp;quot;%p&amp;quot;) do -- split at punctuation and iterate&lt;br /&gt;
			p = mw.text.trim(p)&lt;br /&gt;
			for i, v in ipairs( mw.wikibase.getBestStatements(qid, p) ) do&lt;br /&gt;
				local linkedid = v.mainsnak.datavalue and v.mainsnak.datavalue.value.id&lt;br /&gt;
				if linkedid then&lt;br /&gt;
					if all then&lt;br /&gt;
						out[#out+1] = linkedid&lt;br /&gt;
					else&lt;br /&gt;
						return linkedid&lt;br /&gt;
					end -- test for all or just the first one found&lt;br /&gt;
				end -- test for value exists for that property&lt;br /&gt;
			end -- loop through values of property to follow&lt;br /&gt;
		end -- loop through list of properties to follow&lt;br /&gt;
	end&lt;br /&gt;
	if #out &amp;gt; 0 then&lt;br /&gt;
		local ret = &amp;quot;&amp;quot;&lt;br /&gt;
		if list then&lt;br /&gt;
			ret = mw.getCurrentFrame():expandTemplate{title = list, args = out}&lt;br /&gt;
		else&lt;br /&gt;
			ret = table.concat(out, &amp;quot; &amp;quot;)&lt;br /&gt;
		end&lt;br /&gt;
		return ret&lt;br /&gt;
	else&lt;br /&gt;
		return qid&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
p.followQid = function(frame)&lt;br /&gt;
	return p._followQid(frame.args)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
-- globalSiteID returns the globalSiteID for the current wiki&lt;br /&gt;
-- e.g. returns &amp;quot;enwiki&amp;quot; for the English Wikipedia, &amp;quot;enwikisource&amp;quot; for English Wikisource, etc.&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
-- Dependencies: none&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
p.globalSiteID = function(frame)&lt;br /&gt;
	return mw.wikibase.getGlobalSiteId()&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
-- siteID returns the root of the globalSiteID&lt;br /&gt;
-- e.g. &amp;quot;en&amp;quot; for &amp;quot;enwiki&amp;quot;, &amp;quot;enwikisource&amp;quot;, etc.&lt;br /&gt;
-- treats &amp;quot;en-gb&amp;quot; as &amp;quot;en&amp;quot;, etc.&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
-- Dependencies: none&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
p.siteID = function(frame)&lt;br /&gt;
	local txtlang = frame:callParserFunction(&#039;int&#039;, {&#039;lang&#039;}) or &amp;quot;&amp;quot;&lt;br /&gt;
	-- This deals with specific exceptions: be-tarask -&amp;gt; be-x-old&lt;br /&gt;
	if txtlang == &amp;quot;be-tarask&amp;quot; then&lt;br /&gt;
		return &amp;quot;be_x_old&amp;quot;&lt;br /&gt;
	end&lt;br /&gt;
	local pos = txtlang:find(&amp;quot;-&amp;quot;)&lt;br /&gt;
	local ret = &amp;quot;&amp;quot;&lt;br /&gt;
	if pos then&lt;br /&gt;
		ret = txtlang:sub(1, pos-1)&lt;br /&gt;
	else&lt;br /&gt;
		ret = txtlang&lt;br /&gt;
	end&lt;br /&gt;
	return ret&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
-- projID returns the code used to link to the reader&#039;s language&#039;s project&lt;br /&gt;
-- e.g &amp;quot;en&amp;quot; for [[:en:WikidataIB]]&lt;br /&gt;
-- treats &amp;quot;en-gb&amp;quot; as &amp;quot;en&amp;quot;, etc.&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
-- Dependencies: none&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
p.projID = function(frame)&lt;br /&gt;
	local txtlang = frame:callParserFunction(&#039;int&#039;, {&#039;lang&#039;}) or &amp;quot;&amp;quot;&lt;br /&gt;
	-- This deals with specific exceptions: be-tarask -&amp;gt; be-x-old&lt;br /&gt;
	if txtlang == &amp;quot;be-tarask&amp;quot; then&lt;br /&gt;
		return &amp;quot;be-x-old&amp;quot;&lt;br /&gt;
	end&lt;br /&gt;
	local pos = txtlang:find(&amp;quot;-&amp;quot;)&lt;br /&gt;
	local ret = &amp;quot;&amp;quot;&lt;br /&gt;
	if pos then&lt;br /&gt;
		ret = txtlang:sub(1, pos-1)&lt;br /&gt;
	else&lt;br /&gt;
		ret = txtlang&lt;br /&gt;
	end&lt;br /&gt;
	return ret&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
-- formatNumber formats a number according to the the supplied language code (&amp;quot;|lang=&amp;quot;)&lt;br /&gt;
-- or the default language if not supplied.&lt;br /&gt;
-- The number is the first unnamed parameter or &amp;quot;|num=&amp;quot;&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
-- Dependencies: findLang()&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
p.formatNumber = function(frame)&lt;br /&gt;
	local lang&lt;br /&gt;
	local num = tonumber(frame.args[1] or frame.args.num) or 0&lt;br /&gt;
	lang = findLang(frame.args.lang)&lt;br /&gt;
	return lang:formatNum( num )&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
-- examine dumps the property (the unnamed parameter or pid)&lt;br /&gt;
-- from the item given by the parameter &#039;qid&#039; (or the other unnamed parameter)&lt;br /&gt;
-- or from the item corresponding to the current page if qid is not supplied.&lt;br /&gt;
-- e.g. {{#invoke:WikidataIB |examine |pid=P26 |qid=Q42}}&lt;br /&gt;
-- or {{#invoke:WikidataIB |examine |P26 |Q42}} or any combination of these&lt;br /&gt;
-- or {{#invoke:WikidataIB |examine |P26}} for the current page.&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
-- Dependencies: none&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
p.examine = function( frame )&lt;br /&gt;
	local args&lt;br /&gt;
	if frame.args[1] or frame.args.pid or frame.args.qid then&lt;br /&gt;
		args = frame.args&lt;br /&gt;
	else&lt;br /&gt;
		args = frame:getParent().args&lt;br /&gt;
	end&lt;br /&gt;
	local par = {}&lt;br /&gt;
	local pid = (args.pid or &amp;quot;&amp;quot;):upper()&lt;br /&gt;
	local qid = (args.qid or &amp;quot;&amp;quot;):upper()&lt;br /&gt;
	par[1] = mw.text.trim( args[1] or &amp;quot;&amp;quot; ):upper()&lt;br /&gt;
	par[2] = mw.text.trim( args[2] or &amp;quot;&amp;quot; ):upper()&lt;br /&gt;
	table.sort(par)&lt;br /&gt;
	if par[2]:sub(1,1) == &amp;quot;P&amp;quot; then par[1], par[2] = par[2], par[1] end&lt;br /&gt;
	if pid == &amp;quot;&amp;quot; then pid = par[1] end&lt;br /&gt;
	if qid == &amp;quot;&amp;quot; then qid = par[2] end&lt;br /&gt;
	local q1 = qid:sub(1,1)&lt;br /&gt;
	if pid:sub(1,1) ~= &amp;quot;P&amp;quot; then return &amp;quot;No property supplied&amp;quot; end&lt;br /&gt;
	if q1 ~= &amp;quot;Q&amp;quot; and q1 ~= &amp;quot;M&amp;quot; then qid = mw.wikibase.getEntityIdForCurrentPage() end&lt;br /&gt;
	if not qid then return &amp;quot;No item for this page&amp;quot; end&lt;br /&gt;
	return &amp;quot;&amp;lt;pre&amp;gt;&amp;quot; .. mw.dumpObject( mw.wikibase.getAllStatements( qid, pid ) ) .. &amp;quot;&amp;lt;/pre&amp;gt;&amp;quot;&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
-- checkvalue looks for &#039;val&#039; as a wikibase-item value of a property (the unnamed parameter or pid)&lt;br /&gt;
-- from the item given by the parameter &#039;qid&#039;&lt;br /&gt;
-- or from the Wikidata item associated with the current page if qid is not supplied.&lt;br /&gt;
-- It only checks ranks that are requested (preferred and normal by default)&lt;br /&gt;
-- If property is not supplied, then P31 (instance of) is assumed.&lt;br /&gt;
-- It returns val if found or nothing if not found.&lt;br /&gt;
-- e.g. {{#invoke:WikidataIB |checkvalue |val=Q5 |pid=P31 |qid=Q42}}&lt;br /&gt;
-- or {{#invoke:WikidataIB |checkvalue |val=Q5 |P31 |qid=Q42}}&lt;br /&gt;
-- or {{#invoke:WikidataIB |checkvalue |val=Q5 |qid=Q42}}&lt;br /&gt;
-- or {{#invoke:WikidataIB |checkvalue |val=Q5 |P31}} for the current page.&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
-- Dependencies: none&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
p.checkvalue = function( frame )&lt;br /&gt;
	local args&lt;br /&gt;
	if frame.args.val then&lt;br /&gt;
		args = frame.args&lt;br /&gt;
	else&lt;br /&gt;
		args = frame:getParent().args&lt;br /&gt;
	end&lt;br /&gt;
	local val = args.val&lt;br /&gt;
	if not val then return nil end&lt;br /&gt;
	local pid = mw.text.trim(args.pid or args[1] or &amp;quot;P31&amp;quot;):upper()&lt;br /&gt;
	local qid = (args.qid or &amp;quot;&amp;quot;):upper()&lt;br /&gt;
	if pid:sub(1,1) ~= &amp;quot;P&amp;quot; then return nil end&lt;br /&gt;
	if qid:sub(1,1) ~= &amp;quot;Q&amp;quot; then qid = mw.wikibase.getEntityIdForCurrentPage() end&lt;br /&gt;
	if not qid then return nil end&lt;br /&gt;
	local ranks = setRanks(args.rank)&lt;br /&gt;
	local stats = {}&lt;br /&gt;
	if ranks.b then&lt;br /&gt;
		stats = mw.wikibase.getBestStatements(qid, pid)&lt;br /&gt;
	else&lt;br /&gt;
		stats = mw.wikibase.getAllStatements( qid, pid )&lt;br /&gt;
	end&lt;br /&gt;
	if not stats[1] then return nil end&lt;br /&gt;
	if stats[1].mainsnak.datatype == &amp;quot;wikibase-item&amp;quot; then&lt;br /&gt;
		for k, v in pairs( stats ) do&lt;br /&gt;
			local ms = v.mainsnak&lt;br /&gt;
			if ranks[v.rank:sub(1,1)] and ms.snaktype == &amp;quot;value&amp;quot; and ms.datavalue.value.id == val then&lt;br /&gt;
				return val&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	return nil&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
-- url2 takes a parameter url= that is a proper url and formats it for use in an infobox.&lt;br /&gt;
-- If no parameter is supplied, it returns nothing.&lt;br /&gt;
-- This is the equivalent of Template:URL&lt;br /&gt;
-- but it keeps the &amp;quot;edit at Wikidata&amp;quot; pen icon out of the microformat.&lt;br /&gt;
-- Usually it will take its url parameter directly from a Wikidata call:&lt;br /&gt;
-- e.g. {{#invoke:WikidataIB |url2 |url={{wdib |P856 |qid=Q23317 |fwd=ALL |osd=no}} }}&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
-- Dependencies: none&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
p.url2 = function(frame)&lt;br /&gt;
	local txt = frame.args.url or &amp;quot;&amp;quot;&lt;br /&gt;
	if txt == &amp;quot;&amp;quot; then return nil end&lt;br /&gt;
	-- extract any icon&lt;br /&gt;
	local url, icon = txt:match(&amp;quot;(.+)&amp;amp;nbsp;(.+)&amp;quot;)&lt;br /&gt;
	-- make sure there&#039;s at least a space at the end&lt;br /&gt;
	url = (url or txt) .. &amp;quot; &amp;quot;&lt;br /&gt;
	icon = icon or &amp;quot;&amp;quot;&lt;br /&gt;
	-- extract any protocol like https://&lt;br /&gt;
	local prot = url:match(&amp;quot;(https*://).+[ \&amp;quot;\&#039;]&amp;quot;)&lt;br /&gt;
	-- extract address&lt;br /&gt;
	local addr = &amp;quot;&amp;quot;&lt;br /&gt;
	if prot then&lt;br /&gt;
		addr = url:match(&amp;quot;https*://(.+)[ \&amp;quot;\&#039;]&amp;quot;) or &amp;quot; &amp;quot;&lt;br /&gt;
	else&lt;br /&gt;
		prot = &amp;quot;//&amp;quot;&lt;br /&gt;
		addr = url:match(&amp;quot;[^%p%s]+%.(.+)[ \&amp;quot;\&#039;]&amp;quot;) or &amp;quot; &amp;quot;&lt;br /&gt;
	end&lt;br /&gt;
	-- strip trailing / from end of domain-only url and add &amp;lt;wbr/&amp;gt; before . and /&lt;br /&gt;
	local disp, n = addr:gsub( &amp;quot;^([^/]+)/$&amp;quot;, &amp;quot;%1&amp;quot; ):gsub(&amp;quot;%/&amp;quot;, &amp;quot;&amp;lt;wbr/&amp;gt;/&amp;quot;):gsub(&amp;quot;%.&amp;quot;, &amp;quot;&amp;lt;wbr/&amp;gt;.&amp;quot;)&lt;br /&gt;
	return &#039;&amp;lt;span class=&amp;quot;url&amp;quot;&amp;gt;[&#039; .. prot .. addr .. &amp;quot; &amp;quot; .. disp .. &amp;quot;]&amp;lt;/span&amp;gt;&amp;amp;nbsp;&amp;quot; .. icon&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
-- getWebsite fetches the Official website (P856) and formats it for use in an infobox.&lt;br /&gt;
-- This is similar to Template:Official website but with a url displayed,&lt;br /&gt;
-- and it adds the &amp;quot;edit at Wikidata&amp;quot; pen icon beyond the microformat if enabled.&lt;br /&gt;
-- A local value will override the Wikidata value. &amp;quot;NONE&amp;quot; returns nothing.&lt;br /&gt;
-- e.g. {{#invoke:WikidataIB |getWebsite |qid= |noicon= |lang= |url= }}&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
-- Dependencies: findLang(); parseParam();&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
p.getWebsite = function(frame)&lt;br /&gt;
	local url = frame.args.url or &amp;quot;&amp;quot;&lt;br /&gt;
	if url:upper() == &amp;quot;NONE&amp;quot; then return nil end&lt;br /&gt;
	local urls = {}&lt;br /&gt;
	local quals = {}&lt;br /&gt;
	local qid = frame.args.qid or &amp;quot;&amp;quot;&lt;br /&gt;
	if url and url ~= &amp;quot;&amp;quot; then&lt;br /&gt;
		urls[1] = url&lt;br /&gt;
	else&lt;br /&gt;
		if qid == &amp;quot;&amp;quot; then qid = mw.wikibase.getEntityIdForCurrentPage() end&lt;br /&gt;
		if not qid then return nil end&lt;br /&gt;
&lt;br /&gt;
		local prop856 = mw.wikibase.getBestStatements(qid, &amp;quot;P856&amp;quot;)&lt;br /&gt;
		for k, v in pairs(prop856) do&lt;br /&gt;
			if v.mainsnak.snaktype == &amp;quot;value&amp;quot; then&lt;br /&gt;
				urls[#urls+1] = v.mainsnak.datavalue.value&lt;br /&gt;
				if v.qualifiers and v.qualifiers[&amp;quot;P1065&amp;quot;] then&lt;br /&gt;
					 -- just take the first archive url (P1065)&lt;br /&gt;
					local au = v.qualifiers[&amp;quot;P1065&amp;quot;][1]&lt;br /&gt;
					if au.snaktype == &amp;quot;value&amp;quot; then&lt;br /&gt;
						quals[#urls] = au.datavalue.value&lt;br /&gt;
					end -- test for archive url having a value&lt;br /&gt;
				end -- test for qualifers&lt;br /&gt;
			end -- test for website having a value&lt;br /&gt;
		end -- loop through website(s)&lt;br /&gt;
	end&lt;br /&gt;
	if #urls == 0 then return nil end&lt;br /&gt;
&lt;br /&gt;
	local out = {}&lt;br /&gt;
	for i, u in ipairs(urls) do&lt;br /&gt;
		local link = quals[i] or u&lt;br /&gt;
		local prot, addr = u:match(&amp;quot;(http[s]*://)(.+)&amp;quot;)&lt;br /&gt;
		addr = addr or u&lt;br /&gt;
		local disp, n = addr:gsub(&amp;quot;%.&amp;quot;, &amp;quot;&amp;lt;wbr/&amp;gt;%.&amp;quot;)&lt;br /&gt;
		out[#out+1] = &#039;&amp;lt;span class=&amp;quot;url&amp;quot;&amp;gt;[&#039; .. link .. &amp;quot; &amp;quot; .. disp .. &amp;quot;]&amp;lt;/span&amp;gt;&amp;quot;&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	local langcode = findLang(frame.args.lang).code&lt;br /&gt;
	local noicon = parseParam(frame.args.noicon, false)&lt;br /&gt;
	if url == &amp;quot;&amp;quot; and not noicon then&lt;br /&gt;
		out[#out] = out[#out] .. createicon(langcode, qid, &amp;quot;P856&amp;quot;)&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	local ret = &amp;quot;&amp;quot;&lt;br /&gt;
	if #out &amp;gt; 1 then&lt;br /&gt;
		ret = mw.getCurrentFrame():expandTemplate{title = &amp;quot;ubl&amp;quot;, args = out}&lt;br /&gt;
	else&lt;br /&gt;
		ret = out[1]&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	return ret&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
-- getAllLabels fetches the set of labels and formats it for display as wikitext.&lt;br /&gt;
-- It takes a parameter &#039;qid&#039; for arbitrary access, otherwise it uses the current page.&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
-- Dependencies: none&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
p.getAllLabels = function(frame)&lt;br /&gt;
	local args = frame.args or frame:getParent().args or {}&lt;br /&gt;
&lt;br /&gt;
	local qid = args.qid or &amp;quot;&amp;quot;&lt;br /&gt;
	if qid == &amp;quot;&amp;quot; then qid = mw.wikibase.getEntityIdForCurrentPage() end&lt;br /&gt;
	if not qid or not mw.wikibase.entityExists(qid) then return i18n[&amp;quot;entity-not-found&amp;quot;] end&lt;br /&gt;
&lt;br /&gt;
	local labels = mw.wikibase.getEntity(qid).labels&lt;br /&gt;
	if not labels then return i18n[&amp;quot;labels-not-found&amp;quot;] end&lt;br /&gt;
&lt;br /&gt;
	local out = {}&lt;br /&gt;
	for k, v in pairs(labels) do&lt;br /&gt;
		out[#out+1] = v.value .. &amp;quot; (&amp;quot; .. v.language .. &amp;quot;)&amp;quot;&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	return table.concat(out, &amp;quot;; &amp;quot;)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
-- getAllDescriptions fetches the set of descriptions and formats it for display as wikitext.&lt;br /&gt;
-- It takes a parameter &#039;qid&#039; for arbitrary access, otherwise it uses the current page.&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
-- Dependencies: none&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
p.getAllDescriptions = function(frame)&lt;br /&gt;
	local args = frame.args or frame:getParent().args or {}&lt;br /&gt;
&lt;br /&gt;
	local qid = args.qid or &amp;quot;&amp;quot;&lt;br /&gt;
	if qid == &amp;quot;&amp;quot; then qid = mw.wikibase.getEntityIdForCurrentPage() end&lt;br /&gt;
	if not qid or not mw.wikibase.entityExists(qid) then return i18n[&amp;quot;entity-not-found&amp;quot;] end&lt;br /&gt;
&lt;br /&gt;
	local descriptions = mw.wikibase.getEntity(qid).descriptions&lt;br /&gt;
	if not descriptions then return i18n[&amp;quot;descriptions-not-found&amp;quot;] end&lt;br /&gt;
&lt;br /&gt;
	local out = {}&lt;br /&gt;
	for k, v in pairs(descriptions) do&lt;br /&gt;
		out[#out+1] = v.value .. &amp;quot; (&amp;quot; .. v.language .. &amp;quot;)&amp;quot;&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	return table.concat(out, &amp;quot;; &amp;quot;)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
-- getAllAliases fetches the set of aliases and formats it for display as wikitext.&lt;br /&gt;
-- It takes a parameter &#039;qid&#039; for arbitrary access, otherwise it uses the current page.&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
-- Dependencies: none&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
p.getAllAliases = function(frame)&lt;br /&gt;
	local args = frame.args or frame:getParent().args or {}&lt;br /&gt;
&lt;br /&gt;
	local qid = args.qid or &amp;quot;&amp;quot;&lt;br /&gt;
	if qid == &amp;quot;&amp;quot; then qid = mw.wikibase.getEntityIdForCurrentPage() end&lt;br /&gt;
	if not qid or not mw.wikibase.entityExists(qid) then return i18n[&amp;quot;entity-not-found&amp;quot;] end&lt;br /&gt;
&lt;br /&gt;
	local aliases = mw.wikibase.getEntity(qid).aliases&lt;br /&gt;
	if not aliases then return i18n[&amp;quot;aliases-not-found&amp;quot;] end&lt;br /&gt;
&lt;br /&gt;
	local out = {}&lt;br /&gt;
	for k1, v1 in pairs(aliases) do&lt;br /&gt;
		local lang = v1[1].language&lt;br /&gt;
		local val = {}&lt;br /&gt;
		for k1, v2 in ipairs(v1) do&lt;br /&gt;
			val[#val+1] = v2.value&lt;br /&gt;
		end&lt;br /&gt;
		out[#out+1] = table.concat(val, &amp;quot;, &amp;quot;) .. &amp;quot; (&amp;quot; .. lang .. &amp;quot;)&amp;quot;&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	return table.concat(out, &amp;quot;; &amp;quot;)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
-- showNoLinks displays the article titles that should not be linked.&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
-- Dependencies: none&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
p.showNoLinks = function(frame)&lt;br /&gt;
	local out = {}&lt;br /&gt;
	for k, v in pairs(donotlink) do&lt;br /&gt;
		out[#out+1] = k&lt;br /&gt;
	end&lt;br /&gt;
	table.sort( out )&lt;br /&gt;
	return table.concat(out, &amp;quot;; &amp;quot;)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
-- checkValidity checks whether the first unnamed parameter represents a valid entity-id,&lt;br /&gt;
-- that is, something like Q1235 or P123.&lt;br /&gt;
-- It returns the strings &amp;quot;true&amp;quot; or &amp;quot;false&amp;quot;.&lt;br /&gt;
-- Change false to nil to return &amp;quot;true&amp;quot; or &amp;quot;&amp;quot; (easier to test with #if:).&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
-- Dependencies: none&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
function p.checkValidity(frame)&lt;br /&gt;
	local id = mw.text.trim(frame.args[1] or &amp;quot;&amp;quot;)&lt;br /&gt;
	if mw.wikibase.isValidEntityId(id) then&lt;br /&gt;
		return true&lt;br /&gt;
	else&lt;br /&gt;
		return false&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
-- getEntityFromTitle returns the Entity-ID (Q-number) for a given title.&lt;br /&gt;
-- Modification of Module:ResolveEntityId&lt;br /&gt;
-- The title is the first unnamed parameter.&lt;br /&gt;
-- The site parameter determines the site/language for the title. Defaults to current wiki.&lt;br /&gt;
-- The showdab parameter determines whether dab pages should return the Q-number or nil. Defaults to true.&lt;br /&gt;
-- Returns the Q-number or nil if it does not exist.&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
-- Dependencies: parseParam&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
function p.getEntityFromTitle(frame)&lt;br /&gt;
	local args=frame.args&lt;br /&gt;
	if not args[1] then args=frame:getParent().args end&lt;br /&gt;
	if not args[1] then return nil end&lt;br /&gt;
	local title = mw.text.trim(args[1])&lt;br /&gt;
	local site = args.site or &amp;quot;&amp;quot;&lt;br /&gt;
	local showdab = parseParam(args.showdab, true)&lt;br /&gt;
	local qid = mw.wikibase.getEntityIdForTitle(title, site)&lt;br /&gt;
	if qid then&lt;br /&gt;
		local prop31 = mw.wikibase.getBestStatements(qid, &amp;quot;P31&amp;quot;)[1]&lt;br /&gt;
		if not showdab and prop31 and prop31.mainsnak.datavalue.value.id == &amp;quot;Q4167410&amp;quot; then&lt;br /&gt;
			return nil&lt;br /&gt;
		else&lt;br /&gt;
			return qid&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
-- getDatePrecision returns the number representing the precision of the first best date value&lt;br /&gt;
-- for the given property.&lt;br /&gt;
-- It takes the qid and property ID&lt;br /&gt;
-- The meanings are given at https://www.mediawiki.org/wiki/Wikibase/DataModel#Dates_and_times&lt;br /&gt;
-- 0 = 1 billion years .. 6 = millennium, 7 = century, 8 = decade, 9 = year, 10 = month, 11 = day&lt;br /&gt;
-- Returns 0 (or the second unnamed parameter) if the Wikidata does not exist.&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
-- Dependencies: parseParam; sourced;&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
function p.getDatePrecision(frame)&lt;br /&gt;
	local args=frame.args&lt;br /&gt;
	if not args[1] then args=frame:getParent().args end&lt;br /&gt;
	local default = tonumber(args[2] or args.default) or 0&lt;br /&gt;
	local prop = mw.text.trim(args[1] or &amp;quot;&amp;quot;)&lt;br /&gt;
	if prop == &amp;quot;&amp;quot; then return default end&lt;br /&gt;
	local qid = args.qid or &amp;quot;&amp;quot;&lt;br /&gt;
	if qid == &amp;quot;&amp;quot; then qid = mw.wikibase.getEntityIdForCurrentPage() end&lt;br /&gt;
	if not qid then return default end&lt;br /&gt;
	local onlysrc = parseParam(args.onlysourced or args.osd, true)&lt;br /&gt;
	local stat = mw.wikibase.getBestStatements(qid, prop)&lt;br /&gt;
	for i, v in ipairs(stat) do&lt;br /&gt;
		local prec = (onlysrc == false or sourced(v))&lt;br /&gt;
			and v.mainsnak.datavalue&lt;br /&gt;
			and v.mainsnak.datavalue.value&lt;br /&gt;
			and v.mainsnak.datavalue.value.precision&lt;br /&gt;
		if prec then return prec end&lt;br /&gt;
	end&lt;br /&gt;
	return default&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
return p&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
-- List of exported functions&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
--[[&lt;br /&gt;
_getValue&lt;br /&gt;
getValue&lt;br /&gt;
getPreferredValue&lt;br /&gt;
getCoords&lt;br /&gt;
getQualifierValue&lt;br /&gt;
getSumOfParts&lt;br /&gt;
getValueByQual&lt;br /&gt;
getValueByLang&lt;br /&gt;
getValueByRefSource&lt;br /&gt;
getPropertyIDs&lt;br /&gt;
getQualifierIDs&lt;br /&gt;
getPropOfProp&lt;br /&gt;
getAwardCat&lt;br /&gt;
getIntersectCat&lt;br /&gt;
getGlobe&lt;br /&gt;
getCommonsLink&lt;br /&gt;
getSiteLink&lt;br /&gt;
getLink&lt;br /&gt;
getLabel&lt;br /&gt;
label&lt;br /&gt;
getAT&lt;br /&gt;
getDescription&lt;br /&gt;
getAliases&lt;br /&gt;
pageId&lt;br /&gt;
formatDate&lt;br /&gt;
location&lt;br /&gt;
checkBlacklist&lt;br /&gt;
emptyor&lt;br /&gt;
labelorid&lt;br /&gt;
getLang&lt;br /&gt;
getItemLangCode&lt;br /&gt;
findLanguage&lt;br /&gt;
getQID&lt;br /&gt;
followQid&lt;br /&gt;
globalSiteID&lt;br /&gt;
siteID&lt;br /&gt;
projID&lt;br /&gt;
formatNumber&lt;br /&gt;
examine&lt;br /&gt;
checkvalue&lt;br /&gt;
url2&lt;br /&gt;
getWebsite&lt;br /&gt;
getAllLabels&lt;br /&gt;
getAllDescriptions&lt;br /&gt;
getAllAliases&lt;br /&gt;
showNoLinks&lt;br /&gt;
checkValidity&lt;br /&gt;
getEntityFromTitle&lt;br /&gt;
getDatePrecision&lt;br /&gt;
--]]&lt;br /&gt;
-------------------------------------------------------------------------------&lt;/div&gt;</summary>
		<author><name>Marie</name></author>
	</entry>
	<entry>
		<id>http://project-au.w.kmwc.org/index.php?title=Module:Multilingual&amp;diff=2085</id>
		<title>Module:Multilingual</title>
		<link rel="alternate" type="text/html" href="http://project-au.w.kmwc.org/index.php?title=Module:Multilingual&amp;diff=2085"/>
		<updated>2026-01-16T10:07:18Z</updated>

		<summary type="html">&lt;p&gt;Marie: 1 revision imported&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;local Multilingual = { suite   = &amp;quot;Multilingual&amp;quot;,&lt;br /&gt;
                       serial  = &amp;quot;2020-12-10&amp;quot;,&lt;br /&gt;
                       item    = 47541920,&lt;br /&gt;
                       globals = { ISO15924 = 71584769,&lt;br /&gt;
                                   WLink    = 19363224 }&lt;br /&gt;
                     }&lt;br /&gt;
--[=[&lt;br /&gt;
Utilities for multilingual texts and ISO 639 (BCP47) issues etc.&lt;br /&gt;
* fair()&lt;br /&gt;
* fallback()&lt;br /&gt;
* findCode()&lt;br /&gt;
* fix()&lt;br /&gt;
* format()&lt;br /&gt;
* getBase()&lt;br /&gt;
* getLang()&lt;br /&gt;
* getName()&lt;br /&gt;
* i18n()&lt;br /&gt;
* int()&lt;br /&gt;
* isLang()&lt;br /&gt;
* isLangWiki()&lt;br /&gt;
* isMinusculable()&lt;br /&gt;
* isRTL()&lt;br /&gt;
* message()&lt;br /&gt;
* sitelink()&lt;br /&gt;
* tabData()&lt;br /&gt;
* userLang()&lt;br /&gt;
* userLangCode()&lt;br /&gt;
* wikibase()&lt;br /&gt;
* failsafe()&lt;br /&gt;
loadData: Multilingual/config Multilingual/names&lt;br /&gt;
]=]&lt;br /&gt;
local Failsafe   = Multilingual&lt;br /&gt;
local GlobalMod  = Multilingual&lt;br /&gt;
local GlobalData = Multilingual&lt;br /&gt;
local User       = { sniffer = &amp;quot;showpreview&amp;quot; }&lt;br /&gt;
Multilingual.globals.Multilingual = Multilingual.item&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Multilingual.exotic = { simple = true,&lt;br /&gt;
                        no     = true }&lt;br /&gt;
Multilingual.prefer = { cs = true,&lt;br /&gt;
                        de = true,&lt;br /&gt;
                        en = true,&lt;br /&gt;
                        es = true,&lt;br /&gt;
                        fr = true,&lt;br /&gt;
                        it = true,&lt;br /&gt;
                        nl = true,&lt;br /&gt;
                        pt = true,&lt;br /&gt;
                        ru = true,&lt;br /&gt;
                        sv = true }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
local foreignModule = function ( access, advanced, append, alt, alert )&lt;br /&gt;
    -- Fetch global module&lt;br /&gt;
    -- Precondition:&lt;br /&gt;
    --     access    -- string, with name of base module&lt;br /&gt;
    --     advanced  -- true, for require(); else mw.loadData()&lt;br /&gt;
    --     append    -- string, with subpage part, if any; or false&lt;br /&gt;
    --     alt       -- number, of wikidata item of root; or false&lt;br /&gt;
    --     alert     -- true, for throwing error on data problem&lt;br /&gt;
    -- Postcondition:&lt;br /&gt;
    --     Returns whatever, probably table&lt;br /&gt;
    -- 2020-01-01&lt;br /&gt;
    local storage = access&lt;br /&gt;
    local finer = function ()&lt;br /&gt;
                      if append then&lt;br /&gt;
                          storage = string.format( &amp;quot;%s/%s&amp;quot;,&lt;br /&gt;
                                                   storage,&lt;br /&gt;
                                                   append )&lt;br /&gt;
                      end&lt;br /&gt;
                  end&lt;br /&gt;
    local fun, lucky, r, suited&lt;br /&gt;
    if advanced then&lt;br /&gt;
        fun = require&lt;br /&gt;
    else&lt;br /&gt;
        fun = mw.loadData&lt;br /&gt;
    end&lt;br /&gt;
    GlobalMod.globalModules = GlobalMod.globalModules or { }&lt;br /&gt;
    suited = GlobalMod.globalModules[ access ]&lt;br /&gt;
    if not suited then&lt;br /&gt;
        finer()&lt;br /&gt;
        lucky, r = pcall( fun,  &amp;quot;Module:&amp;quot; .. storage )&lt;br /&gt;
    end&lt;br /&gt;
    if not lucky then&lt;br /&gt;
        if not suited  and&lt;br /&gt;
           type( alt ) == &amp;quot;number&amp;quot;  and&lt;br /&gt;
           alt &amp;gt; 0 then&lt;br /&gt;
            suited = string.format( &amp;quot;Q%d&amp;quot;, alt )&lt;br /&gt;
            suited = mw.wikibase.getSitelink( suited )&lt;br /&gt;
            GlobalMod.globalModules[ access ] = suited or true&lt;br /&gt;
        end&lt;br /&gt;
        if type( suited ) == &amp;quot;string&amp;quot; then&lt;br /&gt;
            storage = suited&lt;br /&gt;
            finer()&lt;br /&gt;
            lucky, r = pcall( fun, storage )&lt;br /&gt;
        end&lt;br /&gt;
        if not lucky and alert then&lt;br /&gt;
            error( &amp;quot;Missing or invalid page: &amp;quot; .. storage )&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
    return r&lt;br /&gt;
end -- foreignModule()&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
local fetchData = function ( access )&lt;br /&gt;
    -- Retrieve translated keyword from commons:Data:****.tab&lt;br /&gt;
    -- Precondition:&lt;br /&gt;
    --     access  -- string, with page identification on Commons&lt;br /&gt;
    --     Returns table, with data, or string, with error message&lt;br /&gt;
    -- 2019-12-05&lt;br /&gt;
    local storage = access&lt;br /&gt;
    local r&lt;br /&gt;
    if type( storage ) == &amp;quot;string&amp;quot; then&lt;br /&gt;
        local s&lt;br /&gt;
        storage = mw.text.trim( storage )&lt;br /&gt;
        s = storage:lower()&lt;br /&gt;
        if s:sub( 1, 2 ) == &amp;quot;c:&amp;quot; then&lt;br /&gt;
            storage = mw.text.trim( storage:sub( 3 ) )&lt;br /&gt;
            s       = storage:lower()&lt;br /&gt;
        elseif s:sub( 1, 8 ) == &amp;quot;commons:&amp;quot; then&lt;br /&gt;
            storage = mw.text.trim( storage:sub( 9 ) )&lt;br /&gt;
            s       = storage:lower()&lt;br /&gt;
        end&lt;br /&gt;
        if s:sub( 1, 5 ) == &amp;quot;data:&amp;quot; then&lt;br /&gt;
            storage = mw.text.trim( storage:sub( 6 ) )&lt;br /&gt;
            s       = storage:lower()&lt;br /&gt;
        end&lt;br /&gt;
        if s == &amp;quot;&amp;quot;  or  s == &amp;quot;.tab&amp;quot; then&lt;br /&gt;
            storage = false&lt;br /&gt;
        elseif s:sub( -4 ) == &amp;quot;.tab&amp;quot; then&lt;br /&gt;
            storage = storage:sub( 1, -5 ) .. &amp;quot;.tab&amp;quot;&lt;br /&gt;
        else&lt;br /&gt;
            storage = storage .. &amp;quot;.tab&amp;quot;&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
    if type( storage ) == &amp;quot;string&amp;quot; then&lt;br /&gt;
        local data&lt;br /&gt;
        if type( GlobalData.TabDATA ) ~= &amp;quot;table&amp;quot; then&lt;br /&gt;
            GlobalData.TabDATA = { }&lt;br /&gt;
        end&lt;br /&gt;
        data = GlobalData.TabDATA[ storage ]&lt;br /&gt;
        if data then&lt;br /&gt;
            r = data&lt;br /&gt;
        else&lt;br /&gt;
            local lucky&lt;br /&gt;
            lucky, data = pcall( mw.ext.data.get, storage, &amp;quot;_&amp;quot; )&lt;br /&gt;
            if type( data ) == &amp;quot;table&amp;quot; then&lt;br /&gt;
                data = data.data&lt;br /&gt;
                if type( data ) == &amp;quot;table&amp;quot; then&lt;br /&gt;
                    GlobalData.TabDATA[ storage ] = data&lt;br /&gt;
                else&lt;br /&gt;
                    r = string.format( &amp;quot;%s [[%s%s]]&amp;quot;,&lt;br /&gt;
                                       &amp;quot;INVALID Data:*.tab&amp;quot;,&lt;br /&gt;
                                       &amp;quot;commons:Data:&amp;quot;,&lt;br /&gt;
                                       storage )&lt;br /&gt;
                end&lt;br /&gt;
            else&lt;br /&gt;
                r = &amp;quot;BAD PAGE Data:*.tab &amp;amp;#8211; commons:&amp;quot; .. storage&lt;br /&gt;
            end&lt;br /&gt;
            if r then&lt;br /&gt;
                GlobalData.TabDATA[ storage ] = r&lt;br /&gt;
                data = false&lt;br /&gt;
            else&lt;br /&gt;
                r = data&lt;br /&gt;
            end&lt;br /&gt;
        end&lt;br /&gt;
    else&lt;br /&gt;
        r = &amp;quot;BAD PAGE commons:Data:*.tab&amp;quot;&lt;br /&gt;
    end&lt;br /&gt;
    return r&lt;br /&gt;
end -- fetchData()&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
local favorites = function ()&lt;br /&gt;
    -- Provide fallback codes&lt;br /&gt;
    -- Postcondition:&lt;br /&gt;
    --     Returns table with sequence of preferred languages&lt;br /&gt;
    --     * ahead elements&lt;br /&gt;
    --     * user (not yet accessible)&lt;br /&gt;
    --     * page content language (not yet accessible)&lt;br /&gt;
    --     * page name subpage&lt;br /&gt;
    --     * project&lt;br /&gt;
    --     * en&lt;br /&gt;
    local r = Multilingual.polyglott&lt;br /&gt;
    if not r then&lt;br /&gt;
        local self = mw.language.getContentLanguage():getCode():lower()&lt;br /&gt;
        local sub  = mw.title.getCurrentTitle().subpageText&lt;br /&gt;
        local f    = function ( add )&lt;br /&gt;
                         local s = add&lt;br /&gt;
                         for i = 1, #r do&lt;br /&gt;
                             if r[ i ] == s then&lt;br /&gt;
                                 s = false&lt;br /&gt;
                                 break -- for i&lt;br /&gt;
                             end&lt;br /&gt;
                         end -- for i&lt;br /&gt;
                         if s then&lt;br /&gt;
                             table.insert( r, s )&lt;br /&gt;
                         end&lt;br /&gt;
                     end&lt;br /&gt;
        r = { }&lt;br /&gt;
        if sub:find( &amp;quot;/&amp;quot;, 2, true ) then&lt;br /&gt;
            sub = sub:match( &amp;quot;/(%l%l%l?)$&amp;quot; )&lt;br /&gt;
            if sub then&lt;br /&gt;
                table.insert( r, sub )&lt;br /&gt;
            end&lt;br /&gt;
        elseif sub:find( &amp;quot;^%l%l%l?%-?%a?%a?%a?%a?$&amp;quot; )  and&lt;br /&gt;
               mw.language.isSupportedLanguage( sub ) then&lt;br /&gt;
            table.insert( r, sub )&lt;br /&gt;
        end&lt;br /&gt;
        f( self )&lt;br /&gt;
        f( &amp;quot;en&amp;quot; )&lt;br /&gt;
        Multilingual.polyglott = r&lt;br /&gt;
    end&lt;br /&gt;
    return r&lt;br /&gt;
end -- favorites()&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
local feasible = function ( ask, accept )&lt;br /&gt;
    -- Is ask to be supported by application?&lt;br /&gt;
    -- Precondition:&lt;br /&gt;
    --     ask     -- lowercase code&lt;br /&gt;
    --     accept  -- sequence table, with offered lowercase codes&lt;br /&gt;
    -- Postcondition:&lt;br /&gt;
    --     nil, or true&lt;br /&gt;
    local r&lt;br /&gt;
    for i = 1, #accept do&lt;br /&gt;
        if accept[ i ] == ask then&lt;br /&gt;
            r = true&lt;br /&gt;
            break -- for i&lt;br /&gt;
        end&lt;br /&gt;
    end -- for i&lt;br /&gt;
    return r&lt;br /&gt;
end -- feasible()&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
local fetch = function ( access, append )&lt;br /&gt;
    -- Attach config or library module&lt;br /&gt;
    -- Precondition:&lt;br /&gt;
    --     access  -- module title&lt;br /&gt;
    --     append  -- string, with subpage part of this; or false&lt;br /&gt;
    -- Postcondition:&lt;br /&gt;
    --     Returns:  table, with library, or false&lt;br /&gt;
    local got, sign&lt;br /&gt;
    if append then&lt;br /&gt;
        sign = string.format( &amp;quot;%s/%s&amp;quot;, access, append )&lt;br /&gt;
    else&lt;br /&gt;
        sign = access&lt;br /&gt;
    end&lt;br /&gt;
    if type( Multilingual.ext ) ~= &amp;quot;table&amp;quot; then&lt;br /&gt;
        Multilingual.ext = { }&lt;br /&gt;
    end&lt;br /&gt;
    got = Multilingual.ext[ sign ]&lt;br /&gt;
    if not got  and  got ~= false then&lt;br /&gt;
        local global = Multilingual.globals[ access ]&lt;br /&gt;
        local lib    = ( not append  or  append == &amp;quot;config&amp;quot; )&lt;br /&gt;
        got = foreignModule( access, lib, append, global )&lt;br /&gt;
        if type( got ) == &amp;quot;table&amp;quot; then&lt;br /&gt;
            if lib then&lt;br /&gt;
                local startup = got[ access ]&lt;br /&gt;
                if type( startup ) == &amp;quot;function&amp;quot; then&lt;br /&gt;
                    got = startup()&lt;br /&gt;
                end&lt;br /&gt;
            end&lt;br /&gt;
        else&lt;br /&gt;
            got = false&lt;br /&gt;
        end&lt;br /&gt;
        Multilingual.ext[ sign ] = got&lt;br /&gt;
    end&lt;br /&gt;
    return got&lt;br /&gt;
end -- fetch()&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
local fetchISO639 = function ( access )&lt;br /&gt;
    -- Retrieve table from commons:Data:ISO639/***.tab&lt;br /&gt;
    -- Precondition:&lt;br /&gt;
    --     access  -- string, with subpage identification&lt;br /&gt;
    -- Postcondition:&lt;br /&gt;
    --     Returns table, with data, even empty&lt;br /&gt;
    local r&lt;br /&gt;
    if type( Multilingual.iso639 ) ~= &amp;quot;table&amp;quot; then&lt;br /&gt;
        Multilingual.iso639 = { }&lt;br /&gt;
    end&lt;br /&gt;
    r = Multilingual.iso639[ access ]&lt;br /&gt;
    if type( r ) == &amp;quot;nil&amp;quot; then&lt;br /&gt;
        local raw = fetchData( &amp;quot;ISO639/&amp;quot; .. access )&lt;br /&gt;
        if type( raw ) == &amp;quot;table&amp;quot; then&lt;br /&gt;
            local t&lt;br /&gt;
            r = { }&lt;br /&gt;
            for i = 1, #raw do&lt;br /&gt;
                t = raw[ i ]&lt;br /&gt;
                if type( t ) == &amp;quot;table&amp;quot;  and&lt;br /&gt;
                   type( t[ 1 ] ) == &amp;quot;string&amp;quot;  and&lt;br /&gt;
                   type( t[ 2 ] ) == &amp;quot;string&amp;quot; then&lt;br /&gt;
                    r[ t[ 1 ] ] =  t[ 2 ]&lt;br /&gt;
                else&lt;br /&gt;
                    break -- for i&lt;br /&gt;
                end&lt;br /&gt;
            end -- for i&lt;br /&gt;
        else&lt;br /&gt;
            r = false&lt;br /&gt;
        end&lt;br /&gt;
        Multilingual.iso639[ access ] = r&lt;br /&gt;
    end&lt;br /&gt;
    return r or { }&lt;br /&gt;
end -- fetchISO639()&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
local fill = function ( access, alien, frame )&lt;br /&gt;
    -- Expand language name template&lt;br /&gt;
    -- Precondition:&lt;br /&gt;
    --     access  -- string, with language code&lt;br /&gt;
    --     alien   -- language code for which to be generated&lt;br /&gt;
    --     frame   -- frame, if available&lt;br /&gt;
    -- Postcondition:&lt;br /&gt;
    --     Returns string&lt;br /&gt;
    local template = Multilingual.tmplLang&lt;br /&gt;
    local r&lt;br /&gt;
    if type( template ) ~= &amp;quot;table&amp;quot; then&lt;br /&gt;
        local cnf = fetch( &amp;quot;Multilingual&amp;quot;, &amp;quot;config&amp;quot; )&lt;br /&gt;
        if cnf then&lt;br /&gt;
            template = cnf.tmplLang&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
    if type( template ) == &amp;quot;table&amp;quot; then&lt;br /&gt;
        local source = template.title&lt;br /&gt;
        local f, lucky, s&lt;br /&gt;
        Multilingual.tmplLang = template&lt;br /&gt;
        if type( source ) ~= &amp;quot;string&amp;quot;  and&lt;br /&gt;
           type( template.namePat ) == &amp;quot;string&amp;quot;  and&lt;br /&gt;
           template.namePat:find( &amp;quot;%s&amp;quot;, 1, true ) then&lt;br /&gt;
            source = string.format( template.namePat, access )&lt;br /&gt;
        end&lt;br /&gt;
        if type( source ) == &amp;quot;string&amp;quot; then&lt;br /&gt;
            if not Multilingual.frame then&lt;br /&gt;
                if frame then&lt;br /&gt;
                    Multilingual.frame = frame&lt;br /&gt;
                else&lt;br /&gt;
                    Multilingual.frame = mw.getCurrentFrame()&lt;br /&gt;
                end&lt;br /&gt;
            end&lt;br /&gt;
            f = function ( a )&lt;br /&gt;
                    return Multilingual.frame:expandTemplate{ title = a }&lt;br /&gt;
                end&lt;br /&gt;
            lucky, s = pcall( f, source )&lt;br /&gt;
            if lucky then&lt;br /&gt;
                r = s&lt;br /&gt;
            end&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
    return r&lt;br /&gt;
end -- fill()&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
local find = function ( ask, alien )&lt;br /&gt;
    -- Derive language code from name&lt;br /&gt;
    -- Precondition:&lt;br /&gt;
    --     ask    -- language name, downcased&lt;br /&gt;
    --     alien  -- language code of ask&lt;br /&gt;
    -- Postcondition:&lt;br /&gt;
    --     nil, or string&lt;br /&gt;
    local codes = mw.language.fetchLanguageNames( alien, &amp;quot;all&amp;quot; )&lt;br /&gt;
    local r&lt;br /&gt;
    for k, v in pairs( codes ) do&lt;br /&gt;
        if mw.ustring.lower( v ) == ask then&lt;br /&gt;
            r = k&lt;br /&gt;
            break -- for k, v&lt;br /&gt;
        end&lt;br /&gt;
    end -- for k, v&lt;br /&gt;
    if not r then&lt;br /&gt;
        r = Multilingual.fair( ask )&lt;br /&gt;
    end&lt;br /&gt;
    return r&lt;br /&gt;
end -- find()&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
local fold = function ( frame )&lt;br /&gt;
    -- Merge template and #invoke arglist&lt;br /&gt;
    -- Precondition:&lt;br /&gt;
    --     frame   -- template frame&lt;br /&gt;
    -- Postcondition:&lt;br /&gt;
    --     table, with combined arglist&lt;br /&gt;
    local r = { }&lt;br /&gt;
    local f = function ( apply )&lt;br /&gt;
                  if type( apply ) == &amp;quot;table&amp;quot;  and&lt;br /&gt;
                     type( apply.args ) == &amp;quot;table&amp;quot; then&lt;br /&gt;
                      for k, v in pairs( apply.args ) do&lt;br /&gt;
                          v = mw.text.trim( v )&lt;br /&gt;
                          if v ~= &amp;quot;&amp;quot; then&lt;br /&gt;
                              r[ tostring( k ) ] = v&lt;br /&gt;
                          end&lt;br /&gt;
                      end -- for k, v&lt;br /&gt;
                  end&lt;br /&gt;
              end -- f()&lt;br /&gt;
    f( frame:getParent() )&lt;br /&gt;
    f( frame )&lt;br /&gt;
    return r&lt;br /&gt;
end -- fold()&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
User.favorize = function ( accept, frame )&lt;br /&gt;
    -- Guess user language&lt;br /&gt;
    -- Precondition:&lt;br /&gt;
    --     accept  -- sequence table, with offered ISO 639 etc. codes&lt;br /&gt;
    --     frame   -- frame, if available&lt;br /&gt;
    -- Postcondition:&lt;br /&gt;
    --     Returns string with best code, or nil&lt;br /&gt;
    if not ( User.self or User.langs ) then&lt;br /&gt;
        if not User.trials then&lt;br /&gt;
            User.tell = mw.message.new( User.sniffer )&lt;br /&gt;
            if User.tell:exists() then&lt;br /&gt;
                User.trials = { }&lt;br /&gt;
                if not Multilingual.frame then&lt;br /&gt;
                    if frame then&lt;br /&gt;
                        Multilingual.frame = frame&lt;br /&gt;
                    else&lt;br /&gt;
                        Multilingual.frame = mw.getCurrentFrame()&lt;br /&gt;
                    end&lt;br /&gt;
                end&lt;br /&gt;
                User.sin = Multilingual.frame:callParserFunction( &amp;quot;int&amp;quot;,&lt;br /&gt;
                                                           User.sniffer )&lt;br /&gt;
            else&lt;br /&gt;
                User.langs = true&lt;br /&gt;
            end&lt;br /&gt;
        end&lt;br /&gt;
        if User.sin then&lt;br /&gt;
            local order  = { }&lt;br /&gt;
            local post   = { }&lt;br /&gt;
            local three  = { }&lt;br /&gt;
            local unfold = { }&lt;br /&gt;
            local s, sin&lt;br /&gt;
            for i = 1, #accept do&lt;br /&gt;
                s = accept[ i ]&lt;br /&gt;
                if not User.trials[ s ] then&lt;br /&gt;
                    if #s &amp;gt; 2 then&lt;br /&gt;
                        if s:find( &amp;quot;-&amp;quot;, 3, true ) then&lt;br /&gt;
                            table.insert( unfold, s )&lt;br /&gt;
                        else&lt;br /&gt;
                            table.insert( three, s )&lt;br /&gt;
                        end&lt;br /&gt;
                    else&lt;br /&gt;
                        if Multilingual.prefer[ s ] then&lt;br /&gt;
                            table.insert( order, s )&lt;br /&gt;
                        else&lt;br /&gt;
                            table.insert( post, s )&lt;br /&gt;
                        end&lt;br /&gt;
                    end&lt;br /&gt;
                end&lt;br /&gt;
            end -- for i&lt;br /&gt;
            for i = 1, #post do&lt;br /&gt;
                table.insert( order, post[ i ] )&lt;br /&gt;
            end -- for i&lt;br /&gt;
            for i = 1, #three do&lt;br /&gt;
                table.insert( order, three[ i ] )&lt;br /&gt;
            end -- for i&lt;br /&gt;
            for i = 1, #unfold do&lt;br /&gt;
                table.insert( order, unfold[ i ] )&lt;br /&gt;
            end -- for i&lt;br /&gt;
            for i = 1, #order do&lt;br /&gt;
                s = order[ i ]&lt;br /&gt;
                sin = User.tell:inLanguage( s ):plain()&lt;br /&gt;
                if sin == User.sin then&lt;br /&gt;
                    User.self = s&lt;br /&gt;
                    break -- for i&lt;br /&gt;
                else&lt;br /&gt;
                    User.trials[ s ] = true&lt;br /&gt;
                end&lt;br /&gt;
            end -- for i&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
    return User.self&lt;br /&gt;
end -- User.favorize()&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Multilingual.fair = function ( ask )&lt;br /&gt;
    -- Format language specification according to RFC 5646 etc.&lt;br /&gt;
    -- Precondition:&lt;br /&gt;
    --     ask  -- string or table, as created by .getLang()&lt;br /&gt;
    -- Postcondition:&lt;br /&gt;
    --     Returns string, or false&lt;br /&gt;
    local s = type( ask )&lt;br /&gt;
    local q, r&lt;br /&gt;
    if s == &amp;quot;table&amp;quot; then&lt;br /&gt;
        q = ask&lt;br /&gt;
    elseif s == &amp;quot;string&amp;quot; then&lt;br /&gt;
        q = Multilingual.getLang( ask )&lt;br /&gt;
    end&lt;br /&gt;
    if q  and&lt;br /&gt;
       q.legal  and&lt;br /&gt;
       mw.language.isKnownLanguageTag( q.base ) then&lt;br /&gt;
        r = q.base&lt;br /&gt;
        if q.n &amp;gt; 1 then&lt;br /&gt;
            local order = { &amp;quot;extlang&amp;quot;,&lt;br /&gt;
                            &amp;quot;script&amp;quot;,&lt;br /&gt;
                            &amp;quot;region&amp;quot;,&lt;br /&gt;
                            &amp;quot;other&amp;quot;,&lt;br /&gt;
                            &amp;quot;extension&amp;quot; }&lt;br /&gt;
            for i = 1, #order do&lt;br /&gt;
                s = q[ order[ i ] ]&lt;br /&gt;
                if s then&lt;br /&gt;
                    r =  string.format( &amp;quot;%s-%s&amp;quot;, r, s )&lt;br /&gt;
                end&lt;br /&gt;
            end -- for i&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
    return r or false&lt;br /&gt;
end -- Multilingual.fair()&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Multilingual.fallback = function ( able, another )&lt;br /&gt;
    -- Is another language suitable as replacement?&lt;br /&gt;
    -- Precondition:&lt;br /&gt;
    --     able     -- language version specifier to be supported&lt;br /&gt;
    --     another  -- language specifier of a possible replacement,&lt;br /&gt;
    --                 or not to retrieve a fallback table&lt;br /&gt;
    -- Postcondition:&lt;br /&gt;
    --     Returns boolean, or table with fallback codes&lt;br /&gt;
    local r&lt;br /&gt;
    if type( able ) == &amp;quot;string&amp;quot;  and  #able &amp;gt; 0 then&lt;br /&gt;
        if type( another ) == &amp;quot;string&amp;quot;  and  #another &amp;gt; 0 then&lt;br /&gt;
            if able == another then&lt;br /&gt;
                r = true&lt;br /&gt;
            else&lt;br /&gt;
                local s = Multilingual.getBase( able )&lt;br /&gt;
                if s == another then&lt;br /&gt;
                    r = true&lt;br /&gt;
                else&lt;br /&gt;
                    local others = mw.language.getFallbacksFor( s )&lt;br /&gt;
                    r = feasible( another, others )&lt;br /&gt;
                end&lt;br /&gt;
            end&lt;br /&gt;
        else&lt;br /&gt;
            local s = Multilingual.getBase( able )&lt;br /&gt;
            if s then&lt;br /&gt;
                r = mw.language.getFallbacksFor( s )&lt;br /&gt;
                if r[ 1 ] == &amp;quot;en&amp;quot; then&lt;br /&gt;
                    local d = fetchISO639( &amp;quot;fallback&amp;quot; )&lt;br /&gt;
                    if type( d ) == &amp;quot;table&amp;quot;  and&lt;br /&gt;
                       type( d[ s ] ) == &amp;quot;string&amp;quot; then&lt;br /&gt;
                        r = mw.text.split( d[ s ], &amp;quot;|&amp;quot; )&lt;br /&gt;
                        table.insert( r, &amp;quot;en&amp;quot; )&lt;br /&gt;
                    end&lt;br /&gt;
                end&lt;br /&gt;
            end&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
    return r or false&lt;br /&gt;
end -- Multilingual.fallback()&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Multilingual.findCode = function ( ask )&lt;br /&gt;
    -- Retrieve code of local (current project or English) language name&lt;br /&gt;
    -- Precondition:&lt;br /&gt;
    --     ask  -- string, with presumable language name&lt;br /&gt;
    --             A code itself will be identified, too.&lt;br /&gt;
    -- Postcondition:&lt;br /&gt;
    --     Returns string, or false&lt;br /&gt;
    local seek = mw.text.trim( ask )&lt;br /&gt;
    local r = false&lt;br /&gt;
    if #seek &amp;gt; 1 then&lt;br /&gt;
        if seek:find( &amp;quot;[&amp;quot;, 1, true ) then&lt;br /&gt;
            local wlink = fetch( &amp;quot;WLink&amp;quot; )&lt;br /&gt;
            if wlink  and&lt;br /&gt;
               type( wlink.getPlain ) == &amp;quot;function&amp;quot; then&lt;br /&gt;
                seek = wlink.getPlain( seek )&lt;br /&gt;
            end&lt;br /&gt;
        end&lt;br /&gt;
        seek = mw.ustring.lower( seek )&lt;br /&gt;
        if Multilingual.isLang( seek ) then&lt;br /&gt;
            r = Multilingual.fair( seek )&lt;br /&gt;
        else&lt;br /&gt;
            local collection = favorites()&lt;br /&gt;
            for i = 1, #collection do&lt;br /&gt;
                r = find( seek, collection[ i ] )&lt;br /&gt;
                if r then&lt;br /&gt;
                    break -- for i&lt;br /&gt;
                end&lt;br /&gt;
            end -- for i&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
    return r&lt;br /&gt;
end -- Multilingual.findCode()&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Multilingual.fix = function ( attempt )&lt;br /&gt;
    -- Fix frequently mistaken language code&lt;br /&gt;
    -- Precondition:&lt;br /&gt;
    --     attempt  -- string, with presumable language code&lt;br /&gt;
    -- Postcondition:&lt;br /&gt;
    --     Returns string with correction, or false if no problem known&lt;br /&gt;
    local r = fetchISO639( &amp;quot;correction&amp;quot; )[ attempt:lower() ]&lt;br /&gt;
    return r or false&lt;br /&gt;
end -- Multilingual.fix()&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Multilingual.format = function ( apply, alien, alter, active, alert,&lt;br /&gt;
                                 frame, assembly, adjacent, ahead )&lt;br /&gt;
    -- Format one or more languages&lt;br /&gt;
    -- Precondition:&lt;br /&gt;
    --     apply     -- string with language list or item&lt;br /&gt;
    --     alien     -- language of the answer&lt;br /&gt;
    --                  -- nil, false, &amp;quot;*&amp;quot;: native&lt;br /&gt;
    --                  -- &amp;quot;!&amp;quot;: current project&lt;br /&gt;
    --                  -- &amp;quot;#&amp;quot;: code, downcased, space separated&lt;br /&gt;
    --                  -- &amp;quot;-&amp;quot;: code, mixcase, space separated&lt;br /&gt;
    --                  -- any valid code&lt;br /&gt;
    --     alter     -- capitalize, if &amp;quot;c&amp;quot;; downcase all, if &amp;quot;d&amp;quot;&lt;br /&gt;
    --                  capitalize first item only, if &amp;quot;f&amp;quot;&lt;br /&gt;
    --                  downcase every first word only, if &amp;quot;m&amp;quot;&lt;br /&gt;
    --     active    -- link items, if true&lt;br /&gt;
    --     alert     -- string with category title in case of error&lt;br /&gt;
    --     frame     -- if available&lt;br /&gt;
    --     assembly  -- string with split pattern, if list expected&lt;br /&gt;
    --     adjacent  -- string with list separator, else assembly&lt;br /&gt;
    --     ahead     -- string to prepend first element, if any&lt;br /&gt;
    -- Postcondition:&lt;br /&gt;
    --     Returns string, or false if apply empty&lt;br /&gt;
    local r = false&lt;br /&gt;
    if apply then&lt;br /&gt;
        local slang&lt;br /&gt;
        if assembly then&lt;br /&gt;
            local bucket = mw.text.split( apply, assembly )&lt;br /&gt;
            local shift = alter&lt;br /&gt;
            local separator&lt;br /&gt;
            if adjacent then&lt;br /&gt;
                separator = adjacent&lt;br /&gt;
            elseif alien == &amp;quot;#&amp;quot;  or  alien == &amp;quot;-&amp;quot; then&lt;br /&gt;
                separator = &amp;quot; &amp;quot;&lt;br /&gt;
            else&lt;br /&gt;
                separator = assembly&lt;br /&gt;
            end&lt;br /&gt;
            for k, v in pairs( bucket ) do&lt;br /&gt;
                slang = Multilingual.format( v, alien, shift, active,&lt;br /&gt;
                                             alert )&lt;br /&gt;
                if slang then&lt;br /&gt;
                    if r then&lt;br /&gt;
                        r = string.format( &amp;quot;%s%s%s&amp;quot;,&lt;br /&gt;
                                           r, separator, slang )&lt;br /&gt;
                    else&lt;br /&gt;
                        r = slang&lt;br /&gt;
                        if shift == &amp;quot;f&amp;quot; then&lt;br /&gt;
                            shift = &amp;quot;d&amp;quot;&lt;br /&gt;
                        end&lt;br /&gt;
                    end&lt;br /&gt;
                end&lt;br /&gt;
            end -- for k, v&lt;br /&gt;
            if r and ahead then&lt;br /&gt;
                r = ahead .. r&lt;br /&gt;
            end&lt;br /&gt;
        else&lt;br /&gt;
            local single = mw.text.trim( apply )&lt;br /&gt;
            if single == &amp;quot;&amp;quot; then&lt;br /&gt;
                r = false&lt;br /&gt;
            else&lt;br /&gt;
                local lapsus, slot&lt;br /&gt;
                slang = Multilingual.findCode( single )&lt;br /&gt;
                if slang then&lt;br /&gt;
                    if alien == &amp;quot;-&amp;quot; then&lt;br /&gt;
                        r = slang&lt;br /&gt;
                    elseif alien == &amp;quot;#&amp;quot; then&lt;br /&gt;
                        r = slang:lower()&lt;br /&gt;
                    else&lt;br /&gt;
                        r = Multilingual.getName( slang, alien )&lt;br /&gt;
                        if active then&lt;br /&gt;
                            slot = fill( slang, false, frame )&lt;br /&gt;
                            if slot then&lt;br /&gt;
                                local wlink = fetch( &amp;quot;WLink&amp;quot; )&lt;br /&gt;
                                if wlink  and&lt;br /&gt;
                                   type( wlink.getTarget )&lt;br /&gt;
                                                       == &amp;quot;function&amp;quot; then&lt;br /&gt;
                                    slot = wlink.getTarget( slot )&lt;br /&gt;
                                end&lt;br /&gt;
                            else&lt;br /&gt;
                                lapsus = alert&lt;br /&gt;
                            end&lt;br /&gt;
                        end&lt;br /&gt;
                    end&lt;br /&gt;
                else&lt;br /&gt;
                    r = single&lt;br /&gt;
                    if active then&lt;br /&gt;
                        local title = mw.title.makeTitle( 0, single )&lt;br /&gt;
                        if title.exists then&lt;br /&gt;
                            slot = single&lt;br /&gt;
                        end&lt;br /&gt;
                    end&lt;br /&gt;
                    lapsus = alert&lt;br /&gt;
                end&lt;br /&gt;
                if not r then&lt;br /&gt;
                    r = single&lt;br /&gt;
                elseif alter == &amp;quot;c&amp;quot; or alter == &amp;quot;f&amp;quot; then&lt;br /&gt;
                    r = mw.ustring.upper( mw.ustring.sub( r, 1, 1 ) )&lt;br /&gt;
                        .. mw.ustring.sub( r, 2 )&lt;br /&gt;
                elseif alter == &amp;quot;d&amp;quot; then&lt;br /&gt;
                    if Multilingual.isMinusculable( slang, r ) then&lt;br /&gt;
                        r = mw.ustring.lower( r )&lt;br /&gt;
                    end&lt;br /&gt;
                elseif alter == &amp;quot;m&amp;quot; then&lt;br /&gt;
                    if Multilingual.isMinusculable( slang, r ) then&lt;br /&gt;
                        r = mw.ustring.lower( mw.ustring.sub( r, 1, 1 ) )&lt;br /&gt;
                            .. mw.ustring.sub( r, 2 )&lt;br /&gt;
                    end&lt;br /&gt;
                end&lt;br /&gt;
                if slot then&lt;br /&gt;
                    if r == slot then&lt;br /&gt;
                        r = string.format( &amp;quot;[[%s]]&amp;quot;, r )&lt;br /&gt;
                    else&lt;br /&gt;
                        r = string.format( &amp;quot;[[%s|%s]]&amp;quot;, slot, r )&lt;br /&gt;
                    end&lt;br /&gt;
                end&lt;br /&gt;
                if lapsus and alert then&lt;br /&gt;
                    r = string.format( &amp;quot;%s[[Category:%s]]&amp;quot;, r, alert )&lt;br /&gt;
                end&lt;br /&gt;
            end&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
    return r&lt;br /&gt;
end -- Multilingual.format()&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Multilingual.getBase = function ( ask )&lt;br /&gt;
    -- Retrieve base language from possibly combined ISO language code&lt;br /&gt;
    -- Precondition:&lt;br /&gt;
    --     ask  -- language code&lt;br /&gt;
    -- Postcondition:&lt;br /&gt;
    --     Returns string, or false&lt;br /&gt;
    local r&lt;br /&gt;
    if ask then&lt;br /&gt;
        local slang = ask:match( &amp;quot;^%s*(%a%a%a?)-?%a*%s*$&amp;quot; )&lt;br /&gt;
        if slang then&lt;br /&gt;
            r = slang:lower()&lt;br /&gt;
        else&lt;br /&gt;
            r = false&lt;br /&gt;
        end&lt;br /&gt;
    else&lt;br /&gt;
        r = false&lt;br /&gt;
    end&lt;br /&gt;
    return r&lt;br /&gt;
end -- Multilingual.getBase()&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Multilingual.getLang = function ( ask )&lt;br /&gt;
    -- Retrieve components of a RFC 5646 language code&lt;br /&gt;
    -- Precondition:&lt;br /&gt;
    --     ask  -- language code with subtags&lt;br /&gt;
    -- Postcondition:&lt;br /&gt;
    --     Returns table with formatted subtags&lt;br /&gt;
    --             .base&lt;br /&gt;
    --             .region&lt;br /&gt;
    --             .script&lt;br /&gt;
    --             .suggest&lt;br /&gt;
    --             .year&lt;br /&gt;
    --             .extension&lt;br /&gt;
    --             .other&lt;br /&gt;
    --             .n&lt;br /&gt;
    local tags = mw.text.split( ask, &amp;quot;-&amp;quot; )&lt;br /&gt;
    local s    = tags[ 1 ]&lt;br /&gt;
    local r&lt;br /&gt;
    if s:match( &amp;quot;^%a%a%a?$&amp;quot; ) then&lt;br /&gt;
        r = { base  = s:lower(),&lt;br /&gt;
              legal = true,&lt;br /&gt;
              n     = #tags }&lt;br /&gt;
        for i = 2, r.n do&lt;br /&gt;
            s = tags[ i ]&lt;br /&gt;
            if #s == 2 then&lt;br /&gt;
                if r.region  or  not s:match( &amp;quot;%a%a&amp;quot; ) then&lt;br /&gt;
                    r.legal = false&lt;br /&gt;
                else&lt;br /&gt;
                    r.region = s:upper()&lt;br /&gt;
                end&lt;br /&gt;
            elseif #s == 4 then&lt;br /&gt;
                if s:match( &amp;quot;%a%a%a%a&amp;quot; ) then&lt;br /&gt;
                    r.legal = ( not r.script )&lt;br /&gt;
                    r.script = s:sub( 1, 1 ):upper() ..&lt;br /&gt;
                               s:sub( 2 ):lower()&lt;br /&gt;
                elseif s:match( &amp;quot;20%d%d&amp;quot; )  or&lt;br /&gt;
                       s:match( &amp;quot;1%d%d%d&amp;quot; ) then&lt;br /&gt;
                    r.legal = ( not r.year )&lt;br /&gt;
                    r.year = s&lt;br /&gt;
                else&lt;br /&gt;
                    r.legal = false&lt;br /&gt;
                end&lt;br /&gt;
            elseif #s == 3 then&lt;br /&gt;
                if r.extlang  or  not s:match( &amp;quot;%a%a%a&amp;quot; ) then&lt;br /&gt;
                    r.legal = false&lt;br /&gt;
                else&lt;br /&gt;
                    r.extlang = s:lower()&lt;br /&gt;
                end&lt;br /&gt;
            elseif #s == 1 then&lt;br /&gt;
                s = s:lower()&lt;br /&gt;
                if s:match( &amp;quot;[tux]&amp;quot; ) then&lt;br /&gt;
                    r.extension = s&lt;br /&gt;
                    for k = i + 1, r.n do&lt;br /&gt;
                        s = tags[ k ]&lt;br /&gt;
                        if s:match( &amp;quot;^%w+$&amp;quot; ) then&lt;br /&gt;
                            r.extension = string.format( &amp;quot;%s-%s&amp;quot;,&lt;br /&gt;
                                                         r.extension, s )&lt;br /&gt;
                        else&lt;br /&gt;
                            r.legal = false&lt;br /&gt;
                        end&lt;br /&gt;
                    end -- for k&lt;br /&gt;
                else&lt;br /&gt;
                    r.legal = false&lt;br /&gt;
                end&lt;br /&gt;
                break -- for i&lt;br /&gt;
            else&lt;br /&gt;
                r.legal = ( not r.other )  and&lt;br /&gt;
                          s:match( &amp;quot;%a%a%a&amp;quot; )&lt;br /&gt;
                r.other = s:lower()&lt;br /&gt;
            end&lt;br /&gt;
            if not r.legal then&lt;br /&gt;
                break -- for i&lt;br /&gt;
            end&lt;br /&gt;
        end -- for i&lt;br /&gt;
        if r.legal then&lt;br /&gt;
            r.suggest = Multilingual.fix( r.base )&lt;br /&gt;
            if r.suggest then&lt;br /&gt;
                r.legal = false&lt;br /&gt;
            end&lt;br /&gt;
        end&lt;br /&gt;
    else&lt;br /&gt;
        r = { legal = false }&lt;br /&gt;
    end&lt;br /&gt;
    if not r.legal then&lt;br /&gt;
        local cnf = fetch( &amp;quot;Multilingual&amp;quot;, &amp;quot;config&amp;quot; )&lt;br /&gt;
        if cnf  and  type( cnf.scream ) == &amp;quot;string&amp;quot; then&lt;br /&gt;
            r.scream = cnf.scream&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
    return r&lt;br /&gt;
end -- Multilingual.getLang()&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Multilingual.getName = function ( ask, alien )&lt;br /&gt;
    -- Which name is assigned to this language code?&lt;br /&gt;
    -- Precondition:&lt;br /&gt;
    --     ask    -- language code&lt;br /&gt;
    --     alien  -- language of the answer&lt;br /&gt;
    --               -- nil, false, &amp;quot;*&amp;quot;: native&lt;br /&gt;
    --               -- &amp;quot;!&amp;quot;: current project&lt;br /&gt;
    --               -- any valid code&lt;br /&gt;
    -- Postcondition:&lt;br /&gt;
    --     Returns string, or false&lt;br /&gt;
    local r&lt;br /&gt;
    if ask then&lt;br /&gt;
        local slang   = alien&lt;br /&gt;
        local tLang&lt;br /&gt;
        if slang then&lt;br /&gt;
            if slang == &amp;quot;*&amp;quot; then&lt;br /&gt;
                slang = Multilingual.fair( ask )&lt;br /&gt;
            elseif slang == &amp;quot;!&amp;quot; then&lt;br /&gt;
                slang = favorites()[ 1 ]&lt;br /&gt;
            else&lt;br /&gt;
                slang = Multilingual.fair( slang )&lt;br /&gt;
            end&lt;br /&gt;
        else&lt;br /&gt;
            slang = Multilingual.fair( ask )&lt;br /&gt;
        end&lt;br /&gt;
        if not slang then&lt;br /&gt;
            slang = ask or &amp;quot;?????&amp;quot;&lt;br /&gt;
        end&lt;br /&gt;
        slang = slang:lower()&lt;br /&gt;
        tLang = fetch( &amp;quot;Multilingual&amp;quot;, &amp;quot;names&amp;quot; )&lt;br /&gt;
        if tLang then&lt;br /&gt;
            tLang = tLang[ slang ]&lt;br /&gt;
            if tLang then&lt;br /&gt;
                r = tLang[ ask ]&lt;br /&gt;
            end&lt;br /&gt;
        end&lt;br /&gt;
        if not r then&lt;br /&gt;
            if not Multilingual.ext.tMW then&lt;br /&gt;
                Multilingual.ext.tMW = { }&lt;br /&gt;
            end&lt;br /&gt;
            tLang = Multilingual.ext.tMW[ slang ]&lt;br /&gt;
            if tLang == nil then&lt;br /&gt;
                tLang = mw.language.fetchLanguageNames( slang )&lt;br /&gt;
                if tLang then&lt;br /&gt;
                    Multilingual.ext.tMW[ slang ] = tLang&lt;br /&gt;
                else&lt;br /&gt;
                    Multilingual.ext.tMW[ slang ] = false&lt;br /&gt;
                end&lt;br /&gt;
            end&lt;br /&gt;
            if tLang then&lt;br /&gt;
                r = tLang[ ask ]&lt;br /&gt;
            end&lt;br /&gt;
        end&lt;br /&gt;
        if not r then&lt;br /&gt;
            r = mw.language.fetchLanguageName( ask:lower(), slang )&lt;br /&gt;
            if r == &amp;quot;&amp;quot; then&lt;br /&gt;
                r = false&lt;br /&gt;
            end&lt;br /&gt;
        end&lt;br /&gt;
    else&lt;br /&gt;
        r = false&lt;br /&gt;
    end&lt;br /&gt;
    return r&lt;br /&gt;
end -- Multilingual.getName()&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Multilingual.i18n = function ( available, alt, frame )&lt;br /&gt;
    -- Select translatable message&lt;br /&gt;
    -- Precondition:&lt;br /&gt;
    --     available  -- table, with mapping language code ./. text&lt;br /&gt;
    --     alt        -- string|nil|false, with fallback text&lt;br /&gt;
    --     frame      -- frame, if available&lt;br /&gt;
    --     Returns&lt;br /&gt;
    --         1. string|nil|false, with selected message&lt;br /&gt;
    --         2. string|nil|false, with language code&lt;br /&gt;
    local r1, r2&lt;br /&gt;
    if type( available ) == &amp;quot;table&amp;quot; then&lt;br /&gt;
        local codes = { }&lt;br /&gt;
        local trsl  = { }&lt;br /&gt;
        local slang&lt;br /&gt;
        for k, v in pairs( available ) do&lt;br /&gt;
            if type( k ) == &amp;quot;string&amp;quot;  and&lt;br /&gt;
               type( v ) == &amp;quot;string&amp;quot; then&lt;br /&gt;
                slang = mw.text.trim( k:lower() )&lt;br /&gt;
                table.insert( codes, slang )&lt;br /&gt;
                trsl[ slang ] = v&lt;br /&gt;
            end&lt;br /&gt;
        end -- for k, v&lt;br /&gt;
        slang = Multilingual.userLang( codes, frame )&lt;br /&gt;
        if slang  and  trsl[ slang ] then&lt;br /&gt;
            r1 = mw.text.trim( trsl[ slang ] )&lt;br /&gt;
            if r1 == &amp;quot;&amp;quot; then&lt;br /&gt;
                r1 = false&lt;br /&gt;
            else&lt;br /&gt;
                r2 = slang&lt;br /&gt;
            end&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
    if not r1  and  type( alt ) == &amp;quot;string&amp;quot; then&lt;br /&gt;
        r1 = mw.text.trim( alt )&lt;br /&gt;
        if r1 == &amp;quot;&amp;quot; then&lt;br /&gt;
            r1 = false&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
    return r1, r2&lt;br /&gt;
end -- Multilingual.i18n()&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Multilingual.int = function ( access, alien, apply )&lt;br /&gt;
    -- Translated system message&lt;br /&gt;
    -- Precondition:&lt;br /&gt;
    --     access  -- message ID&lt;br /&gt;
    --     alien   -- language code&lt;br /&gt;
    --     apply   -- nil, or sequence table with parameters $1, $2, ...&lt;br /&gt;
    -- Postcondition:&lt;br /&gt;
    --     Returns string, or false&lt;br /&gt;
    local o = mw.message.new( access )&lt;br /&gt;
    local r&lt;br /&gt;
    if o:exists() then&lt;br /&gt;
        if type( alien ) == &amp;quot;string&amp;quot; then&lt;br /&gt;
            o:inLanguage( alien:lower() )&lt;br /&gt;
        end&lt;br /&gt;
        if type( apply ) == &amp;quot;table&amp;quot; then&lt;br /&gt;
            o:params( apply )&lt;br /&gt;
        end&lt;br /&gt;
        r = o:plain()&lt;br /&gt;
    end&lt;br /&gt;
    return r or false&lt;br /&gt;
end -- Multilingual.int()&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Multilingual.isLang = function ( ask, additional )&lt;br /&gt;
    -- Could this be an ISO language code?&lt;br /&gt;
    -- Precondition:&lt;br /&gt;
    --     ask         -- language code&lt;br /&gt;
    --     additional  -- true, if Wiki codes like &amp;quot;simple&amp;quot; permitted&lt;br /&gt;
    -- Postcondition:&lt;br /&gt;
    --     Returns boolean&lt;br /&gt;
    local r, s&lt;br /&gt;
    if additional then&lt;br /&gt;
        s = ask&lt;br /&gt;
    else&lt;br /&gt;
        s = Multilingual.getBase( ask )&lt;br /&gt;
    end&lt;br /&gt;
    if s then&lt;br /&gt;
        r = mw.language.isKnownLanguageTag( s )&lt;br /&gt;
        if r then&lt;br /&gt;
            r = not Multilingual.fix( s )&lt;br /&gt;
        elseif additional then&lt;br /&gt;
            r = Multilingual.exotic[ s ] or false&lt;br /&gt;
        end&lt;br /&gt;
    else&lt;br /&gt;
        r = false&lt;br /&gt;
    end&lt;br /&gt;
    return r&lt;br /&gt;
end -- Multilingual.isLang()&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Multilingual.isLangWiki = function ( ask )&lt;br /&gt;
    -- Could this be a Wiki language version?&lt;br /&gt;
    -- Precondition:&lt;br /&gt;
    --     ask  -- language version specifier&lt;br /&gt;
    -- Postcondition:&lt;br /&gt;
    --     Returns boolean&lt;br /&gt;
    local r&lt;br /&gt;
    local s = Multilingual.getBase( ask )&lt;br /&gt;
    if s then&lt;br /&gt;
        r = mw.language.isSupportedLanguage( s )  or&lt;br /&gt;
            Multilingual.exotic[ ask ]&lt;br /&gt;
    else&lt;br /&gt;
        r = false&lt;br /&gt;
    end&lt;br /&gt;
    return r&lt;br /&gt;
end -- Multilingual.isLangWiki()&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Multilingual.isMinusculable = function ( ask, assigned )&lt;br /&gt;
    -- Could this language name become downcased?&lt;br /&gt;
    -- Precondition:&lt;br /&gt;
    --     ask       -- language code, or nil&lt;br /&gt;
    --     assigned  -- language name, or nil&lt;br /&gt;
    -- Postcondition:&lt;br /&gt;
    --     Returns boolean&lt;br /&gt;
    local r = true&lt;br /&gt;
    if ask then&lt;br /&gt;
        local cnf = fetch( &amp;quot;Multilingual&amp;quot;, &amp;quot;config&amp;quot; )&lt;br /&gt;
        if cnf then&lt;br /&gt;
            local s = string.format( &amp;quot; %s &amp;quot;, ask:lower() )&lt;br /&gt;
            if type( cnf.stopMinusculization ) == &amp;quot;string&amp;quot;&lt;br /&gt;
               and  cnf.stopMinusculization:find( s, 1, true ) then&lt;br /&gt;
                r = false&lt;br /&gt;
            end&lt;br /&gt;
            if r  and  assigned&lt;br /&gt;
               and  type( cnf.seekMinusculization ) == &amp;quot;string&amp;quot;&lt;br /&gt;
               and  cnf.seekMinusculization:find( s, 1, true )&lt;br /&gt;
               and  type( cnf.scanMinusculization ) == &amp;quot;string&amp;quot; then&lt;br /&gt;
                local scan = assigned:gsub( &amp;quot;[%(%)]&amp;quot;, &amp;quot; &amp;quot; ) .. &amp;quot; &amp;quot;&lt;br /&gt;
                if not scan:find( cnf.scanMinusculization ) then&lt;br /&gt;
                    r = false&lt;br /&gt;
                end&lt;br /&gt;
            end&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
    return r&lt;br /&gt;
end -- Multilingual.isMinusculable()&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Multilingual.isRTL = function ( ask )&lt;br /&gt;
    -- Check whether language is written right-to-left&lt;br /&gt;
    -- Precondition:&lt;br /&gt;
    --     ask  -- string, with language (or script) code&lt;br /&gt;
    -- Returns true, if right-to-left&lt;br /&gt;
    local r&lt;br /&gt;
    Multilingual.rtl = Multilingual.rtl or { }&lt;br /&gt;
    r = Multilingual.rtl[ ask ]&lt;br /&gt;
    if type( r ) ~= &amp;quot;boolean&amp;quot; then&lt;br /&gt;
        local bib = fetch( &amp;quot;ISO15924&amp;quot; )&lt;br /&gt;
        if type( bib ) == &amp;quot;table&amp;quot;  and&lt;br /&gt;
           type( bib.isRTL ) == &amp;quot;function&amp;quot; then&lt;br /&gt;
            r = bib.isRTL( ask )&lt;br /&gt;
        else&lt;br /&gt;
            r = mw.language.new( ask ):isRTL()&lt;br /&gt;
        end&lt;br /&gt;
        Multilingual.rtl[ ask ] = r&lt;br /&gt;
    end&lt;br /&gt;
    return r&lt;br /&gt;
end -- Multilingual.isRTL()&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Multilingual.message = function ( arglist, frame )&lt;br /&gt;
    -- Show text in best match of user language like system message&lt;br /&gt;
    -- Precondition:&lt;br /&gt;
    --     arglist  -- template arguments&lt;br /&gt;
    --     frame    -- frame, if available&lt;br /&gt;
    -- Postcondition:&lt;br /&gt;
    --     Returns string with appropriate text&lt;br /&gt;
    local r&lt;br /&gt;
    if type( arglist ) == &amp;quot;table&amp;quot; then&lt;br /&gt;
        local t = { }&lt;br /&gt;
        local m, p, save&lt;br /&gt;
        for k, v in pairs( arglist ) do&lt;br /&gt;
            if type( k ) == &amp;quot;string&amp;quot;  and&lt;br /&gt;
               type( v ) == &amp;quot;string&amp;quot; then&lt;br /&gt;
                v = mw.text.trim( v )&lt;br /&gt;
                if v ~= &amp;quot;&amp;quot; then&lt;br /&gt;
                    if k:match( &amp;quot;^%l%l&amp;quot; ) then&lt;br /&gt;
                        t[ k ] = v&lt;br /&gt;
                    elseif k:match( &amp;quot;^%$%d$&amp;quot; )  and  k ~= &amp;quot;$0&amp;quot; then&lt;br /&gt;
                        p = p or { }&lt;br /&gt;
                        k = tonumber( k:match( &amp;quot;^%$(%d)$&amp;quot; ) )&lt;br /&gt;
                        p[ k ] = v&lt;br /&gt;
                        if not m  or  k &amp;gt; m then&lt;br /&gt;
                            m = k&lt;br /&gt;
                        end&lt;br /&gt;
                    end&lt;br /&gt;
                end&lt;br /&gt;
            end&lt;br /&gt;
        end -- for k, v&lt;br /&gt;
        if type( arglist[ &amp;quot;-&amp;quot; ] ) == &amp;quot;string&amp;quot; then&lt;br /&gt;
            save = arglist[ arglist[ &amp;quot;-&amp;quot; ] ]&lt;br /&gt;
        end&lt;br /&gt;
        r = Multilingual.i18n( t, save, frame )&lt;br /&gt;
        if p  and  r  and  r:find( &amp;quot;$&amp;quot;, 1, true ) then&lt;br /&gt;
            t = { }&lt;br /&gt;
            for i = 1, m do&lt;br /&gt;
                t[ i ] = p[ i ]  or  &amp;quot;&amp;quot;&lt;br /&gt;
            end -- for i&lt;br /&gt;
            r = mw.message.newRawMessage( r, t ):plain()&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
    return r  or  &amp;quot;&amp;quot;&lt;br /&gt;
end -- Multilingual.message()&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Multilingual.sitelink = function ( all, frame )&lt;br /&gt;
    -- Make link at local or other site with optimal linktext translation&lt;br /&gt;
    -- Precondition:&lt;br /&gt;
    --     all    -- string or table or number, item ID or entity&lt;br /&gt;
    --     frame  -- frame, if available&lt;br /&gt;
    -- Postcondition:&lt;br /&gt;
    --     Returns string with any helpful internal link, or plain text&lt;br /&gt;
    local s = type( all )&lt;br /&gt;
    local object, r&lt;br /&gt;
    if s == &amp;quot;table&amp;quot; then&lt;br /&gt;
        object = all&lt;br /&gt;
    elseif s == &amp;quot;string&amp;quot; then&lt;br /&gt;
        object = mw.wikibase.getEntity( all )&lt;br /&gt;
    elseif s == &amp;quot;number&amp;quot; then&lt;br /&gt;
        object = mw.wikibase.getEntity( string.format( &amp;quot;Q%d&amp;quot;, all ) )&lt;br /&gt;
    end&lt;br /&gt;
    if type( object ) == &amp;quot;table&amp;quot; then&lt;br /&gt;
        local collection = object.sitelinks&lt;br /&gt;
        local entry&lt;br /&gt;
        s = false&lt;br /&gt;
        if type( collection ) == &amp;quot;table&amp;quot; then&lt;br /&gt;
            Multilingual.site = Multilingual.site  or&lt;br /&gt;
                                mw.wikibase.getGlobalSiteId()&lt;br /&gt;
            entry = collection[ Multilingual.site ]&lt;br /&gt;
            if entry then&lt;br /&gt;
                s = &amp;quot;:&amp;quot; .. entry.title&lt;br /&gt;
            elseif collection.enwiki then&lt;br /&gt;
                s = &amp;quot;w:en:&amp;quot; .. collection.enwiki.title&lt;br /&gt;
            end&lt;br /&gt;
        end&lt;br /&gt;
        r = Multilingual.wikibase( object, &amp;quot;labels&amp;quot;, frame )&lt;br /&gt;
        if s then&lt;br /&gt;
            if s == &amp;quot;:&amp;quot; .. r then&lt;br /&gt;
                r = string.format( &amp;quot;[[%s]]&amp;quot;, s )&lt;br /&gt;
            else&lt;br /&gt;
                r = string.format( &amp;quot;[[%s|%s]]&amp;quot;, s, r )&lt;br /&gt;
            end&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
    return r  or  &amp;quot;&amp;quot;&lt;br /&gt;
end -- Multilingual.sitelink()&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Multilingual.tabData = function ( access, at, alt, frame )&lt;br /&gt;
    -- Retrieve translated keyword from commons:Data:****.tab&lt;br /&gt;
    -- Precondition:&lt;br /&gt;
    --     access  -- string, with page identification on Commons&lt;br /&gt;
    --     at      -- string, with keyword&lt;br /&gt;
    --     alt     -- string|nil|false, with fallback text&lt;br /&gt;
    --     frame   -- frame, if available&lt;br /&gt;
    --     Returns&lt;br /&gt;
    --         1. string|nil|false, with selected message&lt;br /&gt;
    --         2. language code, or &amp;quot;error&amp;quot;&lt;br /&gt;
    local data = fetchData( access )&lt;br /&gt;
    local r1, r2&lt;br /&gt;
    if  type( data ) == &amp;quot;table&amp;quot; then&lt;br /&gt;
        if type( at ) == &amp;quot;string&amp;quot; then&lt;br /&gt;
            local seek = mw.text.trim( at )&lt;br /&gt;
            if seek == &amp;quot;&amp;quot; then&lt;br /&gt;
                r1 = &amp;quot;EMPTY Multilingual.tabData key&amp;quot;&lt;br /&gt;
            else&lt;br /&gt;
                local e, poly&lt;br /&gt;
                for i = 1, #data do&lt;br /&gt;
                    e = data[ i ]&lt;br /&gt;
                    if type( e ) == &amp;quot;table&amp;quot; then&lt;br /&gt;
                        if e[ 1 ] == seek then&lt;br /&gt;
                            if type( e[ 2 ] ) == &amp;quot;table&amp;quot; then&lt;br /&gt;
                                poly = e[ 2 ]&lt;br /&gt;
                            else&lt;br /&gt;
                                r1 = &amp;quot;INVALID Multilingual.tabData bad #&amp;quot;&lt;br /&gt;
                                                         .. tostring( i )&lt;br /&gt;
                            end&lt;br /&gt;
                            break   -- for i&lt;br /&gt;
                        end&lt;br /&gt;
                    else&lt;br /&gt;
                        break   -- for i&lt;br /&gt;
                    end&lt;br /&gt;
                end   -- for i&lt;br /&gt;
                if poly then&lt;br /&gt;
                    data = poly&lt;br /&gt;
                else&lt;br /&gt;
                    r1 = &amp;quot;UNKNOWN Multilingual.tabData key: &amp;quot; .. seek&lt;br /&gt;
                end&lt;br /&gt;
            end&lt;br /&gt;
        else&lt;br /&gt;
            r1 = &amp;quot;INVALID Multilingual.tabData key&amp;quot;&lt;br /&gt;
        end&lt;br /&gt;
    else&lt;br /&gt;
        r1 = data&lt;br /&gt;
    end&lt;br /&gt;
    if r1 then&lt;br /&gt;
        r2 = &amp;quot;error&amp;quot;&lt;br /&gt;
    elseif data then&lt;br /&gt;
        r1, r2 = Multilingual.i18n( data, alt, frame )&lt;br /&gt;
        r2 = r2 or &amp;quot;error&amp;quot;&lt;br /&gt;
    end&lt;br /&gt;
    return r1, r2&lt;br /&gt;
end -- Multilingual.tabData()&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Multilingual.userLang = function ( accept, frame )&lt;br /&gt;
    -- Try to support user language by application&lt;br /&gt;
    -- Precondition:&lt;br /&gt;
    --     accept  -- string or table&lt;br /&gt;
    --                space separated list of available ISO 639 codes&lt;br /&gt;
    --                Default: project language, or English&lt;br /&gt;
    --     frame   -- frame, if available&lt;br /&gt;
    -- Postcondition:&lt;br /&gt;
    --     Returns string with appropriate code&lt;br /&gt;
    local s = type( accept )&lt;br /&gt;
    local codes, r, slang&lt;br /&gt;
    if s == &amp;quot;string&amp;quot; then&lt;br /&gt;
        codes = mw.text.split( accept:lower(), &amp;quot;%s+&amp;quot; )&lt;br /&gt;
    elseif s == &amp;quot;table&amp;quot; then&lt;br /&gt;
        codes = { }&lt;br /&gt;
        for i = 1, #accept do&lt;br /&gt;
            s = accept[ i ]&lt;br /&gt;
            if type( s ) == &amp;quot;string&amp;quot;  and&lt;br /&gt;
               s ~= &amp;quot;&amp;quot; then&lt;br /&gt;
                table.insert( codes, s:lower() )&lt;br /&gt;
            end&lt;br /&gt;
        end -- for i&lt;br /&gt;
    end&lt;br /&gt;
    slang = User.favorize( codes, frame )&lt;br /&gt;
    if slang then&lt;br /&gt;
        if feasible( slang, codes ) then&lt;br /&gt;
            r = slang&lt;br /&gt;
        elseif slang:find( &amp;quot;-&amp;quot;, 1, true ) then&lt;br /&gt;
            slang = Multilingual.getBase( slang )&lt;br /&gt;
            if feasible( slang, codes ) then&lt;br /&gt;
                r = slang&lt;br /&gt;
            end&lt;br /&gt;
        end&lt;br /&gt;
        if not r then&lt;br /&gt;
            local others = mw.language.getFallbacksFor( slang )&lt;br /&gt;
            for i = 1, #others do&lt;br /&gt;
                slang = others[ i ]&lt;br /&gt;
                if feasible( slang, codes ) then&lt;br /&gt;
                    r = slang&lt;br /&gt;
                    break -- for i&lt;br /&gt;
                end&lt;br /&gt;
            end -- for i&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
    if not r then&lt;br /&gt;
        local back = favorites()&lt;br /&gt;
        for i = 1, #back do&lt;br /&gt;
            slang = back[ i ]&lt;br /&gt;
            if feasible( slang, codes ) then&lt;br /&gt;
                r = slang&lt;br /&gt;
                break -- for i&lt;br /&gt;
            end&lt;br /&gt;
        end -- for i&lt;br /&gt;
        if not r  and  codes[ 1 ] then&lt;br /&gt;
            r = codes[ 1 ]&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
    return r  or  favorites()[ 1 ]&lt;br /&gt;
end -- Multilingual.userLang()&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Multilingual.userLangCode = function ()&lt;br /&gt;
    -- Guess a user language code&lt;br /&gt;
    -- Postcondition:&lt;br /&gt;
    --     Returns code of current best guess&lt;br /&gt;
    return User.self  or  favorites()[ 1 ]&lt;br /&gt;
end -- Multilingual.userLangCode()&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Multilingual.wikibase = function ( all, about, attempt, frame )&lt;br /&gt;
    -- Optimal translation of wikibase component&lt;br /&gt;
    -- Precondition:&lt;br /&gt;
    --     all      -- string or table, object ID or entity&lt;br /&gt;
    --     about    -- boolean, true &amp;quot;descriptions&amp;quot; or false &amp;quot;labels&amp;quot;&lt;br /&gt;
    --     attempt  -- string or not, code of preferred language&lt;br /&gt;
    --     frame    -- frame, if available&lt;br /&gt;
    -- Postcondition:&lt;br /&gt;
    --     Returns&lt;br /&gt;
    --         1. string, with selected message&lt;br /&gt;
    --         2. string, with language code, or not&lt;br /&gt;
    local s = type( all )&lt;br /&gt;
    local object, r, r2&lt;br /&gt;
    if s == &amp;quot;table&amp;quot; then&lt;br /&gt;
        object = all&lt;br /&gt;
    elseif s == &amp;quot;string&amp;quot; then&lt;br /&gt;
        object = mw.wikibase.getEntity( all )&lt;br /&gt;
    end&lt;br /&gt;
    if type( object ) == &amp;quot;table&amp;quot; then&lt;br /&gt;
        if about  and  about ~= &amp;quot;labels&amp;quot; then&lt;br /&gt;
            s = &amp;quot;descriptions&amp;quot;&lt;br /&gt;
        else&lt;br /&gt;
            s = &amp;quot;labels&amp;quot;&lt;br /&gt;
        end&lt;br /&gt;
        object = object[ s ]&lt;br /&gt;
        if type( object ) == &amp;quot;table&amp;quot; then&lt;br /&gt;
            if object[ attempt ] then&lt;br /&gt;
                r  = object[ attempt ].value&lt;br /&gt;
                r2 = attempt&lt;br /&gt;
            else&lt;br /&gt;
                local poly&lt;br /&gt;
                for k, v in pairs( object ) do&lt;br /&gt;
                    poly = poly or { }&lt;br /&gt;
                    poly[ k ] = v.value&lt;br /&gt;
                end -- for k, v&lt;br /&gt;
                if poly then&lt;br /&gt;
                    r, r2 = Multilingual.i18n( poly, nil, frame )&lt;br /&gt;
                end&lt;br /&gt;
            end&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
    return r  or  &amp;quot;&amp;quot;,   r2&lt;br /&gt;
end -- Multilingual.wikibase()&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Failsafe.failsafe = function ( atleast )&lt;br /&gt;
    -- Retrieve versioning and check for compliance&lt;br /&gt;
    -- Precondition:&lt;br /&gt;
    --     atleast  -- string, with required version&lt;br /&gt;
    --                         or wikidata|item|~|@ or false&lt;br /&gt;
    -- Postcondition:&lt;br /&gt;
    --     Returns  string  -- with queried version/item, also if problem&lt;br /&gt;
    --              false   -- if appropriate&lt;br /&gt;
    -- 2020-08-17&lt;br /&gt;
    local since = atleast&lt;br /&gt;
    local last    = ( since == &amp;quot;~&amp;quot; )&lt;br /&gt;
    local linked  = ( since == &amp;quot;@&amp;quot; )&lt;br /&gt;
    local link    = ( since == &amp;quot;item&amp;quot; )&lt;br /&gt;
    local r&lt;br /&gt;
    if last  or  link  or  linked  or  since == &amp;quot;wikidata&amp;quot; then&lt;br /&gt;
        local item = Failsafe.item&lt;br /&gt;
        since = false&lt;br /&gt;
        if type( item ) == &amp;quot;number&amp;quot;  and  item &amp;gt; 0 then&lt;br /&gt;
            local suited = string.format( &amp;quot;Q%d&amp;quot;, item )&lt;br /&gt;
            if link then&lt;br /&gt;
                r = suited&lt;br /&gt;
            else&lt;br /&gt;
                local entity = mw.wikibase.getEntity( suited )&lt;br /&gt;
                if type( entity ) == &amp;quot;table&amp;quot; then&lt;br /&gt;
                    local seek = Failsafe.serialProperty or &amp;quot;P348&amp;quot;&lt;br /&gt;
                    local vsn  = entity:formatPropertyValues( seek )&lt;br /&gt;
                    if type( vsn ) == &amp;quot;table&amp;quot;  and&lt;br /&gt;
                       type( vsn.value ) == &amp;quot;string&amp;quot;  and&lt;br /&gt;
                       vsn.value ~= &amp;quot;&amp;quot; then&lt;br /&gt;
                        if last  and  vsn.value == Failsafe.serial then&lt;br /&gt;
                            r = false&lt;br /&gt;
                        elseif linked then&lt;br /&gt;
                            if mw.title.getCurrentTitle().prefixedText&lt;br /&gt;
                               ==  mw.wikibase.getSitelink( suited ) then&lt;br /&gt;
                                r = false&lt;br /&gt;
                            else&lt;br /&gt;
                                r = suited&lt;br /&gt;
                            end&lt;br /&gt;
                        else&lt;br /&gt;
                            r = vsn.value&lt;br /&gt;
                        end&lt;br /&gt;
                    end&lt;br /&gt;
                end&lt;br /&gt;
            end&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
    if type( r ) == &amp;quot;nil&amp;quot; then&lt;br /&gt;
        if not since  or  since &amp;lt;= Failsafe.serial then&lt;br /&gt;
            r = Failsafe.serial&lt;br /&gt;
        else&lt;br /&gt;
            r = false&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
    return r&lt;br /&gt;
end -- Failsafe.failsafe()&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
-- Export&lt;br /&gt;
local p = { }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
p.fair = function ( frame )&lt;br /&gt;
    -- Format language code&lt;br /&gt;
    --     1  -- language code&lt;br /&gt;
    local s = mw.text.trim( frame.args[ 1 ]  or  &amp;quot;&amp;quot; )&lt;br /&gt;
    return Multilingual.fair( s )  or  &amp;quot;&amp;quot;&lt;br /&gt;
end -- p.fair&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
p.fallback = function ( frame )&lt;br /&gt;
    -- Is another language suitable as replacement?&lt;br /&gt;
    --     1  -- language version specifier to be supported&lt;br /&gt;
    --     2  -- language specifier of a possible replacement&lt;br /&gt;
    local s1 = mw.text.trim( frame.args[ 1 ]  or  &amp;quot;&amp;quot; )&lt;br /&gt;
    local s2 = mw.text.trim( frame.args[ 2 ]  or  &amp;quot;&amp;quot; )&lt;br /&gt;
    local r  = Multilingual.fallback( s1, s2 )&lt;br /&gt;
    if type( r ) == &amp;quot;table&amp;quot; then&lt;br /&gt;
        r = r[ 1 ]&lt;br /&gt;
    else&lt;br /&gt;
        r = r  and  &amp;quot;1&amp;quot;   or   &amp;quot;&amp;quot;&lt;br /&gt;
    end&lt;br /&gt;
    return r&lt;br /&gt;
end -- p.fallback&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
p.findCode = function ( frame )&lt;br /&gt;
    -- Retrieve language code from language name&lt;br /&gt;
    --     1  -- name in current project language&lt;br /&gt;
    local s = mw.text.trim( frame.args[ 1 ]  or  &amp;quot;&amp;quot; )&lt;br /&gt;
    return Multilingual.findCode( s )  or  &amp;quot;&amp;quot;&lt;br /&gt;
end -- p.findCode&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
p.fix = function ( frame )&lt;br /&gt;
    local r = frame.args[ 1 ]&lt;br /&gt;
    if r then&lt;br /&gt;
        r = Multilingual.fix( mw.text.trim( r ) )&lt;br /&gt;
    end&lt;br /&gt;
    return r or &amp;quot;&amp;quot;&lt;br /&gt;
end -- p.fix&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
p.format = function ( frame )&lt;br /&gt;
    -- Format one or more languages&lt;br /&gt;
    --     1          -- language list or item&lt;br /&gt;
    --     slang      -- language of the answer, if not native&lt;br /&gt;
    --                   * -- native&lt;br /&gt;
    --                   ! -- current project&lt;br /&gt;
    --                   any valid code&lt;br /&gt;
    --     shift      -- capitalize, if &amp;quot;c&amp;quot;; downcase, if &amp;quot;d&amp;quot;&lt;br /&gt;
    --                   capitalize first item only, if &amp;quot;f&amp;quot;&lt;br /&gt;
    --     link       -- 1 -- link items&lt;br /&gt;
    --     scream     -- category title in case of error&lt;br /&gt;
    --     split      -- split pattern, if list expected&lt;br /&gt;
    --     separator  -- list separator, else split&lt;br /&gt;
    --     start      -- prepend first element, if any&lt;br /&gt;
    local r&lt;br /&gt;
    local link&lt;br /&gt;
    if frame.args.link == &amp;quot;1&amp;quot; then&lt;br /&gt;
        link = true&lt;br /&gt;
    end&lt;br /&gt;
    r = Multilingual.format( frame.args[ 1 ],&lt;br /&gt;
                             frame.args.slang,&lt;br /&gt;
                             frame.args.shift,&lt;br /&gt;
                             link,&lt;br /&gt;
                             frame.args.scream,&lt;br /&gt;
                             frame,&lt;br /&gt;
                             frame.args.split,&lt;br /&gt;
                             frame.args.separator,&lt;br /&gt;
                             frame.args.start )&lt;br /&gt;
    return r or &amp;quot;&amp;quot;&lt;br /&gt;
end -- p.format&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
p.getBase = function ( frame )&lt;br /&gt;
    -- Retrieve base language from possibly combined ISO language code&lt;br /&gt;
    --     1  -- code&lt;br /&gt;
    local s = mw.text.trim( frame.args[ 1 ]  or  &amp;quot;&amp;quot; )&lt;br /&gt;
    return Multilingual.getBase( s )  or  &amp;quot;&amp;quot;&lt;br /&gt;
end -- p.getBase&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
p.getName = function ( frame )&lt;br /&gt;
    -- Retrieve language name from ISO language code&lt;br /&gt;
    --     1  -- code&lt;br /&gt;
    --     2  -- language to be used for the answer, if not native&lt;br /&gt;
    --           ! -- current project&lt;br /&gt;
    --           * -- native&lt;br /&gt;
    --           any valid code&lt;br /&gt;
    local s     = mw.text.trim( frame.args[ 1 ]  or  &amp;quot;&amp;quot; )&lt;br /&gt;
    local slang = frame.args[ 2 ]&lt;br /&gt;
    local r&lt;br /&gt;
    Multilingual.frame = frame&lt;br /&gt;
    if slang then&lt;br /&gt;
        slang = mw.text.trim( slang )&lt;br /&gt;
    end&lt;br /&gt;
    r = Multilingual.getName( s, slang )&lt;br /&gt;
    return r or &amp;quot;&amp;quot;&lt;br /&gt;
end -- p.getName&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
p.int = function ( frame )&lt;br /&gt;
    -- Translated system message&lt;br /&gt;
    --     1             -- message ID&lt;br /&gt;
    --     lang          -- language code&lt;br /&gt;
    --     $1, $2, ...   -- parameters&lt;br /&gt;
    local sysMsg = frame.args[ 1 ]&lt;br /&gt;
    local r&lt;br /&gt;
    if sysMsg then&lt;br /&gt;
        sysMsg = mw.text.trim( sysMsg )&lt;br /&gt;
        if sysMsg ~= &amp;quot;&amp;quot; then&lt;br /&gt;
            local n     = 0&lt;br /&gt;
            local slang = frame.args.lang&lt;br /&gt;
            local i, params, s&lt;br /&gt;
            if slang == &amp;quot;&amp;quot; then&lt;br /&gt;
                slang = false&lt;br /&gt;
            end&lt;br /&gt;
            for k, v in pairs( frame.args ) do&lt;br /&gt;
                if type( k ) == &amp;quot;string&amp;quot; then&lt;br /&gt;
                    s = k:match( &amp;quot;^%$(%d+)$&amp;quot; )&lt;br /&gt;
                    if s then&lt;br /&gt;
                        i = tonumber( s )&lt;br /&gt;
                        if i &amp;gt; n then&lt;br /&gt;
                            n = i&lt;br /&gt;
                        end&lt;br /&gt;
                    end&lt;br /&gt;
                end&lt;br /&gt;
            end -- for k, v&lt;br /&gt;
            if n &amp;gt; 0 then&lt;br /&gt;
                local s&lt;br /&gt;
                params = { }&lt;br /&gt;
                for i = 1, n do&lt;br /&gt;
                    s = frame.args[ &amp;quot;$&amp;quot; .. tostring( i ) ]  or  &amp;quot;&amp;quot;&lt;br /&gt;
                    table.insert( params, s )&lt;br /&gt;
                end -- for i&lt;br /&gt;
            end&lt;br /&gt;
            r = Multilingual.int( sysMsg, slang, params )&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
    return r or &amp;quot;&amp;quot;&lt;br /&gt;
end -- p.int&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
p.isLang = function ( frame )&lt;br /&gt;
    -- Could this be an ISO language code?&lt;br /&gt;
    --     1  -- code&lt;br /&gt;
    local s = mw.text.trim( frame.args[ 1 ]  or  &amp;quot;&amp;quot; )&lt;br /&gt;
    local lucky, r = pcall( Multilingual.isLang, s )&lt;br /&gt;
    return r and &amp;quot;1&amp;quot; or &amp;quot;&amp;quot;&lt;br /&gt;
end -- p.isLang&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
p.isLangWiki = function ( frame )&lt;br /&gt;
    -- Could this be a Wiki language version?&lt;br /&gt;
    --     1  -- code&lt;br /&gt;
    -- Returns non-empty, if possibly language version&lt;br /&gt;
    local s = mw.text.trim( frame.args[ 1 ]  or  &amp;quot;&amp;quot; )&lt;br /&gt;
    local lucky, r = pcall( Multilingual.isLangWiki, s )&lt;br /&gt;
    return r and &amp;quot;1&amp;quot; or &amp;quot;&amp;quot;&lt;br /&gt;
end -- p.isLangWiki&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
p.isRTL = function ( frame )&lt;br /&gt;
    -- Check whether language is written right-to-left&lt;br /&gt;
    --     1  -- string, with language code&lt;br /&gt;
    -- Returns non-empty, if right-to-left&lt;br /&gt;
    local s = mw.text.trim( frame.args[ 1 ]  or  &amp;quot;&amp;quot; )&lt;br /&gt;
    return Multilingual.isRTL( s ) and &amp;quot;1&amp;quot; or &amp;quot;&amp;quot;&lt;br /&gt;
end -- p.isRTL()&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
p.message = function ( frame )&lt;br /&gt;
    -- Translation of text element&lt;br /&gt;
    return Multilingual.message( fold( frame ), frame )&lt;br /&gt;
end -- p.message&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
p.sitelink = function ( frame )&lt;br /&gt;
    -- Make link at local or other site with optimal linktext translation&lt;br /&gt;
    --     1  -- item ID&lt;br /&gt;
    local s = mw.text.trim( frame.args[ 1 ]  or  &amp;quot;&amp;quot; )&lt;br /&gt;
    local r&lt;br /&gt;
    if s:match( &amp;quot;^%d+$&amp;quot;) then&lt;br /&gt;
        r = tonumber( s )&lt;br /&gt;
    elseif s:match( &amp;quot;^Q%d+$&amp;quot;) then&lt;br /&gt;
        r = s&lt;br /&gt;
    end&lt;br /&gt;
    if r then&lt;br /&gt;
        r = Multilingual.sitelink( r, frame )&lt;br /&gt;
    end&lt;br /&gt;
    return r or s&lt;br /&gt;
end -- p.sitelink&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
p.tabData = function ( frame )&lt;br /&gt;
    -- Retrieve best message text from Commons Data&lt;br /&gt;
    --     1    -- page identification on Commons&lt;br /&gt;
    --     2    -- keyword&lt;br /&gt;
    --     alt  -- fallback text&lt;br /&gt;
    local suite = frame.args[ 1 ]&lt;br /&gt;
    local seek  = frame.args[ 2 ]&lt;br /&gt;
    local salt  = frame.args.alt&lt;br /&gt;
    local r     = Multilingual.tabData( suite, seek, salt, frame )&lt;br /&gt;
    return r&lt;br /&gt;
end -- p.tabData&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
p.userLang = function ( frame )&lt;br /&gt;
    -- Which language does the current user prefer?&lt;br /&gt;
    --     1  -- space separated list of available ISO 639 codes&lt;br /&gt;
    local s = mw.text.trim( frame.args[ 1 ]  or  &amp;quot;&amp;quot; )&lt;br /&gt;
    return Multilingual.userLang( s, frame )&lt;br /&gt;
end -- p.userLang&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
p.wikibase = function ( frame )&lt;br /&gt;
    -- Optimal translation of wikibase component&lt;br /&gt;
    --     1  -- object ID&lt;br /&gt;
    --     2  -- 1 for &amp;quot;descriptions&amp;quot;, 0 for &amp;quot;labels&amp;quot;.&lt;br /&gt;
    --           or either &amp;quot;descriptions&amp;quot; or &amp;quot;labels&amp;quot;&lt;br /&gt;
    local r&lt;br /&gt;
    local s = mw.text.trim( frame.args[ 1 ]  or  &amp;quot;&amp;quot; )&lt;br /&gt;
    if s ~= &amp;quot;&amp;quot; then&lt;br /&gt;
        local s2    = mw.text.trim( frame.args[ 2 ]  or  &amp;quot;0&amp;quot; )&lt;br /&gt;
        local slang = mw.text.trim( frame.args.lang  or  &amp;quot;&amp;quot; )&lt;br /&gt;
        local large = ( s2 ~= &amp;quot;&amp;quot;  and  s2 ~= &amp;quot;0&amp;quot; )&lt;br /&gt;
        if slang == &amp;quot;&amp;quot; then&lt;br /&gt;
            slang = false&lt;br /&gt;
        end&lt;br /&gt;
        r = Multilingual.wikibase( s, large, slang, frame )&lt;br /&gt;
    end&lt;br /&gt;
    return r or &amp;quot;&amp;quot;&lt;br /&gt;
end -- p.wikibase&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
p.failsafe = function ( frame )&lt;br /&gt;
    -- Versioning interface&lt;br /&gt;
    local s = type( frame )&lt;br /&gt;
    local since&lt;br /&gt;
    if s == &amp;quot;table&amp;quot; then&lt;br /&gt;
        since = frame.args[ 1 ]&lt;br /&gt;
    elseif s == &amp;quot;string&amp;quot; then&lt;br /&gt;
        since = frame&lt;br /&gt;
    end&lt;br /&gt;
    if since then&lt;br /&gt;
        since = mw.text.trim( since )&lt;br /&gt;
        if since == &amp;quot;&amp;quot; then&lt;br /&gt;
            since = false&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
    return Failsafe.failsafe( since )  or  &amp;quot;&amp;quot;&lt;br /&gt;
end -- p.failsafe()&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
p.Multilingual = function ()&lt;br /&gt;
    return Multilingual&lt;br /&gt;
end -- p.Multilingual&lt;br /&gt;
&lt;br /&gt;
return p&lt;/div&gt;</summary>
		<author><name>Marie</name></author>
	</entry>
	<entry>
		<id>http://project-au.w.kmwc.org/index.php?title=Module:Wikidata&amp;diff=2083</id>
		<title>Module:Wikidata</title>
		<link rel="alternate" type="text/html" href="http://project-au.w.kmwc.org/index.php?title=Module:Wikidata&amp;diff=2083"/>
		<updated>2026-01-16T10:07:18Z</updated>

		<summary type="html">&lt;p&gt;Marie: 1 revision imported&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;-- vim: set noexpandtab ft=lua ts=4 sw=4:&lt;br /&gt;
require(&#039;Module:No globals&#039;)&lt;br /&gt;
&lt;br /&gt;
local p = {}&lt;br /&gt;
local debug = false&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
------------------------------------------------------------------------------&lt;br /&gt;
-- module local variables and functions&lt;br /&gt;
&lt;br /&gt;
local wiki =&lt;br /&gt;
{&lt;br /&gt;
	langcode = mw.language.getContentLanguage().code&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
-- internationalisation&lt;br /&gt;
local i18n =&lt;br /&gt;
{&lt;br /&gt;
	[&amp;quot;errors&amp;quot;] =&lt;br /&gt;
	{&lt;br /&gt;
		[&amp;quot;property-not-found&amp;quot;] = &amp;quot;Property not found.&amp;quot;,&lt;br /&gt;
		[&amp;quot;entity-not-found&amp;quot;] = &amp;quot;Wikidata entity not found.&amp;quot;,&lt;br /&gt;
		[&amp;quot;unknown-claim-type&amp;quot;] = &amp;quot;Unknown claim type.&amp;quot;,&lt;br /&gt;
		[&amp;quot;unknown-entity-type&amp;quot;] = &amp;quot;Unknown entity type.&amp;quot;,&lt;br /&gt;
		[&amp;quot;qualifier-not-found&amp;quot;] = &amp;quot;Qualifier not found.&amp;quot;,&lt;br /&gt;
		[&amp;quot;site-not-found&amp;quot;] = &amp;quot;Wikimedia project not found.&amp;quot;,&lt;br /&gt;
		[&amp;quot;unknown-datetime-format&amp;quot;] = &amp;quot;Unknown datetime format.&amp;quot;,&lt;br /&gt;
		[&amp;quot;local-article-not-found&amp;quot;] = &amp;quot;Article is not yet available in this wiki.&amp;quot;&lt;br /&gt;
	},&lt;br /&gt;
	[&amp;quot;datetime&amp;quot;] =&lt;br /&gt;
	{&lt;br /&gt;
		-- $1 is a placeholder for the actual number&lt;br /&gt;
		[0] = &amp;quot;$1 billion years&amp;quot;,	-- precision: billion years&lt;br /&gt;
		[1] = &amp;quot;$100 million years&amp;quot;,	-- precision: hundred million years&lt;br /&gt;
		[2] = &amp;quot;$10 million years&amp;quot;,	-- precision: ten million years&lt;br /&gt;
		[3] = &amp;quot;$1 million years&amp;quot;,	-- precision: million years&lt;br /&gt;
		[4] = &amp;quot;$100,000 years&amp;quot;,		-- precision: hundred thousand years&lt;br /&gt;
		[5] = &amp;quot;$10,000 years&amp;quot;,		-- precision: ten thousand years&lt;br /&gt;
		[6] = &amp;quot;$1 millennium&amp;quot;,		-- precision: millennium&lt;br /&gt;
		[7] = &amp;quot;$1 century&amp;quot;,			-- precision: century&lt;br /&gt;
		[8] = &amp;quot;$1s&amp;quot;,				-- precision: decade&lt;br /&gt;
		-- the following use the format of #time parser function&lt;br /&gt;
		[9]  = &amp;quot;Y&amp;quot;,					-- precision: year,&lt;br /&gt;
		[10] = &amp;quot;F Y&amp;quot;,				-- precision: month&lt;br /&gt;
		[11] = &amp;quot;F j, Y&amp;quot;,			-- precision: day&lt;br /&gt;
		[12] = &amp;quot;F j, Y ga&amp;quot;,			-- precision: hour&lt;br /&gt;
		[13] = &amp;quot;F j, Y g:ia&amp;quot;,		-- precision: minute&lt;br /&gt;
		[14] = &amp;quot;F j, Y g:i:sa&amp;quot;,		-- precision: second&lt;br /&gt;
		[&amp;quot;beforenow&amp;quot;] = &amp;quot;$1 BCE&amp;quot;,	-- how to format negative numbers for precisions 0 to 5&lt;br /&gt;
		[&amp;quot;afternow&amp;quot;] = &amp;quot;$1 CE&amp;quot;,		-- how to format positive numbers for precisions 0 to 5&lt;br /&gt;
		[&amp;quot;bc&amp;quot;] = &#039;$1 &amp;quot;BCE&amp;quot;&#039;,		-- how print negative years&lt;br /&gt;
		[&amp;quot;ad&amp;quot;] = &amp;quot;$1&amp;quot;,				-- how print positive years&lt;br /&gt;
		-- the following are for function getDateValue() and getQualifierDateValue()&lt;br /&gt;
		[&amp;quot;default-format&amp;quot;] = &amp;quot;dmy&amp;quot;, -- default value of the #3 (getDateValue) or&lt;br /&gt;
									-- #4 (getQualifierDateValue) argument&lt;br /&gt;
		[&amp;quot;default-addon&amp;quot;] = &amp;quot;BC&amp;quot;,	-- default value of the #4 (getDateValue) or&lt;br /&gt;
									-- #5 (getQualifierDateValue) argument&lt;br /&gt;
		[&amp;quot;prefix-addon&amp;quot;] = false,	-- set to true for languages put &amp;quot;BC&amp;quot; in front of the&lt;br /&gt;
									-- datetime string; or the addon will be suffixed&lt;br /&gt;
		[&amp;quot;addon-sep&amp;quot;] = &amp;quot; &amp;quot;,		-- separator between datetime string and addon (or inverse)&lt;br /&gt;
		[&amp;quot;format&amp;quot;] =				-- options of the 3rd argument&lt;br /&gt;
		{&lt;br /&gt;
			[&amp;quot;mdy&amp;quot;] = &amp;quot;F j, Y&amp;quot;,&lt;br /&gt;
			[&amp;quot;my&amp;quot;] = &amp;quot;F Y&amp;quot;,&lt;br /&gt;
			[&amp;quot;y&amp;quot;] = &amp;quot;Y&amp;quot;,&lt;br /&gt;
			[&amp;quot;dmy&amp;quot;] = &amp;quot;j F Y&amp;quot;,&lt;br /&gt;
			[&amp;quot;ymd&amp;quot;] = &amp;quot;Y-m-d&amp;quot;,&lt;br /&gt;
			[&amp;quot;ym&amp;quot;] = &amp;quot;Y-m&amp;quot;&lt;br /&gt;
		}&lt;br /&gt;
	},&lt;br /&gt;
	[&amp;quot;monolingualtext&amp;quot;] = &#039;&amp;lt;span lang=&amp;quot;%language&amp;quot;&amp;gt;%text&amp;lt;/span&amp;gt;&#039;,&lt;br /&gt;
	[&amp;quot;warnDump&amp;quot;] = &amp;quot;[[Category:Called function &#039;Dump&#039; from module Wikidata]]&amp;quot;,&lt;br /&gt;
	[&amp;quot;ordinal&amp;quot;] =&lt;br /&gt;
	{&lt;br /&gt;
		[1] = &amp;quot;st&amp;quot;,&lt;br /&gt;
		[2] = &amp;quot;nd&amp;quot;,&lt;br /&gt;
		[3] = &amp;quot;rd&amp;quot;,&lt;br /&gt;
		[&amp;quot;default&amp;quot;] = &amp;quot;th&amp;quot;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
if wiki.langcode ~= &amp;quot;en&amp;quot; then&lt;br /&gt;
	--require(&amp;quot;Module:i18n&amp;quot;).loadI18n(&amp;quot;Module:Wikidata/i18n&amp;quot;, i18n)&lt;br /&gt;
	-- got idea from [[:w:Module:Wd]]&lt;br /&gt;
	local module_title; if ... == nil then&lt;br /&gt;
		module_title = mw.getCurrentFrame():getTitle()&lt;br /&gt;
	else&lt;br /&gt;
		module_title = ...&lt;br /&gt;
	end&lt;br /&gt;
	require(&#039;Module:i18n&#039;).loadI18n(module_title..&#039;/i18n&#039;, i18n)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- this function needs to be internationalised along with the above:&lt;br /&gt;
-- takes cardinal numer as a numeric and returns the ordinal as a string&lt;br /&gt;
-- we need three exceptions in English for 1st, 2nd, 3rd, 21st, .. 31st, etc.&lt;br /&gt;
local function makeOrdinal (cardinal)&lt;br /&gt;
	local ordsuffix = i18n.ordinal.default&lt;br /&gt;
	if cardinal % 10 == 1 then&lt;br /&gt;
		ordsuffix = i18n.ordinal[1]&lt;br /&gt;
	elseif cardinal % 10 == 2 then&lt;br /&gt;
		ordsuffix = i18n.ordinal[2]&lt;br /&gt;
	elseif cardinal % 10 == 3 then&lt;br /&gt;
		ordsuffix = i18n.ordinal[3]&lt;br /&gt;
	end&lt;br /&gt;
	-- In English, 1, 21, 31, etc. use &#039;st&#039;, but 11, 111, etc. use &#039;th&#039;&lt;br /&gt;
	-- similarly for 12 and 13, etc.&lt;br /&gt;
	if (cardinal % 100 == 11) or (cardinal % 100 == 12) or (cardinal % 100 == 13) then&lt;br /&gt;
		ordsuffix = i18n.ordinal.default&lt;br /&gt;
	end&lt;br /&gt;
	return tostring(cardinal) .. ordsuffix&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function printError(code)&lt;br /&gt;
	return &#039;&amp;lt;span class=&amp;quot;error&amp;quot;&amp;gt;&#039; .. (i18n.errors[code] or code) .. &#039;&amp;lt;/span&amp;gt;&#039;&lt;br /&gt;
end&lt;br /&gt;
local function parseDateFormat(f, timestamp, addon, prefix_addon, addon_sep) &lt;br /&gt;
	local year_suffix&lt;br /&gt;
	local tstr = &amp;quot;&amp;quot;&lt;br /&gt;
	local lang_obj = mw.language.new(wiki.langcode)&lt;br /&gt;
	local f_parts = mw.text.split(f, &#039;Y&#039;, true)&lt;br /&gt;
	for idx, f_part in pairs(f_parts) do&lt;br /&gt;
		year_suffix = &#039;&#039;&lt;br /&gt;
		if string.match(f_part, &amp;quot;x[mijkot]$&amp;quot;) then&lt;br /&gt;
			-- for non-Gregorian year&lt;br /&gt;
			f_part = f_part .. &#039;Y&#039;&lt;br /&gt;
		elseif idx &amp;lt; #f_parts then&lt;br /&gt;
			-- supress leading zeros in year&lt;br /&gt;
			year_suffix = lang_obj:formatDate(&#039;Y&#039;, timestamp)&lt;br /&gt;
			year_suffix = string.gsub(year_suffix, &#039;^0+&#039;, &#039;&#039;, 1)&lt;br /&gt;
		end&lt;br /&gt;
		tstr = tstr .. lang_obj:formatDate(f_part, timestamp) .. year_suffix&lt;br /&gt;
	end&lt;br /&gt;
	if addon ~= &amp;quot;&amp;quot; and prefix_addon then&lt;br /&gt;
		return addon .. addon_sep .. tstr&lt;br /&gt;
	elseif addon ~= &amp;quot;&amp;quot; then&lt;br /&gt;
		return tstr .. addon_sep .. addon&lt;br /&gt;
	else&lt;br /&gt;
		return tstr&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
local function parseDateValue(timestamp, date_format, date_addon)&lt;br /&gt;
	local prefix_addon = i18n[&amp;quot;datetime&amp;quot;][&amp;quot;prefix-addon&amp;quot;]&lt;br /&gt;
	local addon_sep = i18n[&amp;quot;datetime&amp;quot;][&amp;quot;addon-sep&amp;quot;]&lt;br /&gt;
	local addon = &amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
	-- check for negative date&lt;br /&gt;
	if string.sub(timestamp, 1, 1) == &#039;-&#039; then&lt;br /&gt;
		timestamp = &#039;+&#039; .. string.sub(timestamp, 2)&lt;br /&gt;
		addon = date_addon&lt;br /&gt;
	end&lt;br /&gt;
	local _date_format = i18n[&amp;quot;datetime&amp;quot;][&amp;quot;format&amp;quot;][date_format]&lt;br /&gt;
	if _date_format ~= nil then&lt;br /&gt;
		return parseDateFormat(_date_format, timestamp, addon, prefix_addon, addon_sep)&lt;br /&gt;
	else&lt;br /&gt;
		return printError(&amp;quot;unknown-datetime-format&amp;quot;)&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- This local function combines the year/month/day/BC/BCE handling of parseDateValue{}&lt;br /&gt;
-- with the millennium/century/decade handling of formatDate()&lt;br /&gt;
local function parseDateFull(timestamp, precision, date_format, date_addon)&lt;br /&gt;
	local prefix_addon = i18n[&amp;quot;datetime&amp;quot;][&amp;quot;prefix-addon&amp;quot;]&lt;br /&gt;
	local addon_sep = i18n[&amp;quot;datetime&amp;quot;][&amp;quot;addon-sep&amp;quot;]&lt;br /&gt;
	local addon = &amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
	-- check for negative date&lt;br /&gt;
	if string.sub(timestamp, 1, 1) == &#039;-&#039; then&lt;br /&gt;
		timestamp = &#039;+&#039; .. string.sub(timestamp, 2)&lt;br /&gt;
		addon = date_addon&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- get the next four characters after the + (should be the year now in all cases)&lt;br /&gt;
	-- ok, so this is dirty, but let&#039;s get it working first&lt;br /&gt;
	local intyear = tonumber(string.sub(timestamp, 2, 5))&lt;br /&gt;
	if intyear == 0 and precision &amp;lt;= 9 then&lt;br /&gt;
		return &amp;quot;&amp;quot;&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- precision is 10000 years or more&lt;br /&gt;
	if precision &amp;lt;= 5 then&lt;br /&gt;
		local factor = 10 ^ ((5 - precision) + 4)&lt;br /&gt;
		local y2 = math.ceil(math.abs(intyear) / factor)&lt;br /&gt;
		local relative = mw.ustring.gsub(i18n.datetime[precision], &amp;quot;$1&amp;quot;, tostring(y2))&lt;br /&gt;
		if addon ~= &amp;quot;&amp;quot; then&lt;br /&gt;
			-- negative date&lt;br /&gt;
			relative = mw.ustring.gsub(i18n.datetime.beforenow, &amp;quot;$1&amp;quot;, relative)&lt;br /&gt;
		else&lt;br /&gt;
			relative = mw.ustring.gsub(i18n.datetime.afternow, &amp;quot;$1&amp;quot;, relative)&lt;br /&gt;
		end&lt;br /&gt;
		return relative&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- precision is decades (8), centuries (7) and millennia (6)&lt;br /&gt;
	local era, card&lt;br /&gt;
	if precision == 6 then&lt;br /&gt;
		card = math.floor((intyear - 1) / 1000) + 1&lt;br /&gt;
		era = mw.ustring.gsub(i18n.datetime[6], &amp;quot;$1&amp;quot;, makeOrdinal(card))&lt;br /&gt;
	end&lt;br /&gt;
	if precision == 7 then&lt;br /&gt;
		card = math.floor((intyear - 1) / 100) + 1&lt;br /&gt;
		era = mw.ustring.gsub(i18n.datetime[7], &amp;quot;$1&amp;quot;, makeOrdinal(card))&lt;br /&gt;
	end&lt;br /&gt;
	if precision == 8 then&lt;br /&gt;
		era = mw.ustring.gsub(i18n.datetime[8], &amp;quot;$1&amp;quot;, tostring(math.floor(math.abs(intyear) / 10) * 10))&lt;br /&gt;
	end&lt;br /&gt;
	if era then&lt;br /&gt;
		if addon ~= &amp;quot;&amp;quot; then&lt;br /&gt;
			era = mw.ustring.gsub(mw.ustring.gsub(i18n.datetime.bc, &#039;&amp;quot;&#039;, &amp;quot;&amp;quot;), &amp;quot;$1&amp;quot;, era)&lt;br /&gt;
		else&lt;br /&gt;
			era = mw.ustring.gsub(mw.ustring.gsub(i18n.datetime.ad, &#039;&amp;quot;&#039;, &amp;quot;&amp;quot;), &amp;quot;$1&amp;quot;, era)&lt;br /&gt;
		end&lt;br /&gt;
		return era&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	local _date_format = i18n[&amp;quot;datetime&amp;quot;][&amp;quot;format&amp;quot;][date_format]&lt;br /&gt;
	if _date_format ~= nil then&lt;br /&gt;
		-- check for precision is year and override supplied date_format&lt;br /&gt;
		if precision == 9 then&lt;br /&gt;
			_date_format = i18n[&amp;quot;datetime&amp;quot;][9]&lt;br /&gt;
		end&lt;br /&gt;
		return parseDateFormat(_date_format, timestamp, addon, prefix_addon, addon_sep)&lt;br /&gt;
	else&lt;br /&gt;
		return printError(&amp;quot;unknown-datetime-format&amp;quot;)&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- the &amp;quot;qualifiers&amp;quot; and &amp;quot;snaks&amp;quot; field have a respective &amp;quot;qualifiers-order&amp;quot; and &amp;quot;snaks-order&amp;quot; field&lt;br /&gt;
-- use these as the second parameter and this function instead of the built-in &amp;quot;pairs&amp;quot; function&lt;br /&gt;
-- to iterate over all qualifiers and snaks in the intended order.&lt;br /&gt;
local function orderedpairs(array, order)&lt;br /&gt;
	if not order then return pairs(array) end&lt;br /&gt;
&lt;br /&gt;
	-- return iterator function&lt;br /&gt;
	local i = 0&lt;br /&gt;
	return function()&lt;br /&gt;
		i = i + 1&lt;br /&gt;
		if order[i] then&lt;br /&gt;
			return order[i], array[order[i]]&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- precision: 0 - billion years, 1 - hundred million years, ..., 6 - millennia, 7 - century, 8 - decade, 9 - year, 10 - month, 11 - day, 12 - hour, 13 - minute, 14 - second&lt;br /&gt;
local function normalizeDate(date)&lt;br /&gt;
	date = mw.text.trim(date, &amp;quot;+&amp;quot;)&lt;br /&gt;
	-- extract year&lt;br /&gt;
	local yearstr = mw.ustring.match(date, &amp;quot;^\-?%d+&amp;quot;)&lt;br /&gt;
	local year = tonumber(yearstr)&lt;br /&gt;
	-- remove leading zeros of year&lt;br /&gt;
	return year .. mw.ustring.sub(date, #yearstr + 1), year&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function formatDate(date, precision, timezone)&lt;br /&gt;
	precision = precision or 11&lt;br /&gt;
	local date, year = normalizeDate(date)&lt;br /&gt;
	if year == 0 and precision &amp;lt;= 9 then return &amp;quot;&amp;quot; end&lt;br /&gt;
&lt;br /&gt;
	-- precision is 10000 years or more&lt;br /&gt;
	if precision &amp;lt;= 5 then&lt;br /&gt;
		local factor = 10 ^ ((5 - precision) + 4)&lt;br /&gt;
		local y2 = math.ceil(math.abs(year) / factor)&lt;br /&gt;
		local relative = mw.ustring.gsub(i18n.datetime[precision], &amp;quot;$1&amp;quot;, tostring(y2))&lt;br /&gt;
		if year &amp;lt; 0 then&lt;br /&gt;
			relative = mw.ustring.gsub(i18n.datetime.beforenow, &amp;quot;$1&amp;quot;, relative)&lt;br /&gt;
		else&lt;br /&gt;
			relative = mw.ustring.gsub(i18n.datetime.afternow, &amp;quot;$1&amp;quot;, relative)&lt;br /&gt;
		end&lt;br /&gt;
		return relative&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- precision is decades, centuries and millennia&lt;br /&gt;
	local era&lt;br /&gt;
	if precision == 6 then era = mw.ustring.gsub(i18n.datetime[6], &amp;quot;$1&amp;quot;, tostring(math.floor((math.abs(year) - 1) / 1000) + 1)) end&lt;br /&gt;
	if precision == 7 then era = mw.ustring.gsub(i18n.datetime[7], &amp;quot;$1&amp;quot;, tostring(math.floor((math.abs(year) - 1) / 100) + 1)) end&lt;br /&gt;
	if precision == 8 then era = mw.ustring.gsub(i18n.datetime[8], &amp;quot;$1&amp;quot;, tostring(math.floor(math.abs(year) / 10) * 10)) end&lt;br /&gt;
	if era then&lt;br /&gt;
		if year &amp;lt; 0 then era = mw.ustring.gsub(mw.ustring.gsub(i18n.datetime.bc, &#039;&amp;quot;&#039;, &amp;quot;&amp;quot;), &amp;quot;$1&amp;quot;, era)&lt;br /&gt;
		elseif year &amp;gt; 0 then era = mw.ustring.gsub(mw.ustring.gsub(i18n.datetime.ad, &#039;&amp;quot;&#039;, &amp;quot;&amp;quot;), &amp;quot;$1&amp;quot;, era) end&lt;br /&gt;
		return era&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- precision is year&lt;br /&gt;
	if precision == 9 then&lt;br /&gt;
		return year&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- precision is less than years&lt;br /&gt;
	if precision &amp;gt; 9 then&lt;br /&gt;
		--[[ the following code replaces the UTC suffix with the given negated timezone to convert the global time to the given local time&lt;br /&gt;
		timezone = tonumber(timezone)&lt;br /&gt;
		if timezone and timezone ~= 0 then&lt;br /&gt;
			timezone = -timezone&lt;br /&gt;
			timezone = string.format(&amp;quot;%.2d%.2d&amp;quot;, timezone / 60, timezone % 60)&lt;br /&gt;
			if timezone[1] ~= &#039;-&#039; then timezone = &amp;quot;+&amp;quot; .. timezone end&lt;br /&gt;
			date = mw.text.trim(date, &amp;quot;Z&amp;quot;) .. &amp;quot; &amp;quot; .. timezone&lt;br /&gt;
		end&lt;br /&gt;
		]]--&lt;br /&gt;
&lt;br /&gt;
		local formatstr = i18n.datetime[precision]&lt;br /&gt;
		if year == 0 then formatstr = mw.ustring.gsub(formatstr, i18n.datetime[9], &amp;quot;&amp;quot;)&lt;br /&gt;
		elseif year &amp;lt; 0 then&lt;br /&gt;
			-- Mediawiki formatDate doesn&#039;t support negative years&lt;br /&gt;
			date = mw.ustring.sub(date, 2)&lt;br /&gt;
			formatstr = mw.ustring.gsub(formatstr, i18n.datetime[9], mw.ustring.gsub(i18n.datetime.bc, &amp;quot;$1&amp;quot;, i18n.datetime[9]))&lt;br /&gt;
		elseif year &amp;gt; 0 and i18n.datetime.ad ~= &amp;quot;$1&amp;quot; then&lt;br /&gt;
			formatstr = mw.ustring.gsub(formatstr, i18n.datetime[9], mw.ustring.gsub(i18n.datetime.ad, &amp;quot;$1&amp;quot;, i18n.datetime[9]))&lt;br /&gt;
		end&lt;br /&gt;
		return mw.language.new(wiki.langcode):formatDate(formatstr, date)&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function printDatavalueEntity(data, parameter)&lt;br /&gt;
	-- data fields: entity-type [string], numeric-id [int, Wikidata id]&lt;br /&gt;
	local id&lt;br /&gt;
&lt;br /&gt;
	if data[&amp;quot;entity-type&amp;quot;] == &amp;quot;item&amp;quot; then id = &amp;quot;Q&amp;quot; .. data[&amp;quot;numeric-id&amp;quot;]&lt;br /&gt;
	elseif data[&amp;quot;entity-type&amp;quot;] == &amp;quot;property&amp;quot; then id = &amp;quot;P&amp;quot; .. data[&amp;quot;numeric-id&amp;quot;]&lt;br /&gt;
	else return printError(&amp;quot;unknown-entity-type&amp;quot;)&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	if parameter then&lt;br /&gt;
		if parameter == &amp;quot;link&amp;quot; then&lt;br /&gt;
			local linkTarget = mw.wikibase.getSitelink(id)&lt;br /&gt;
			local linkName = mw.wikibase.getLabel(id)&lt;br /&gt;
			if linkTarget then&lt;br /&gt;
				-- if there is a local Wikipedia article link to it using the label or the article title&lt;br /&gt;
				return &amp;quot;[[&amp;quot; .. linkTarget .. &amp;quot;|&amp;quot; .. (linkName or linkTarget) .. &amp;quot;]]&amp;quot;&lt;br /&gt;
			else&lt;br /&gt;
				-- if there is no local Wikipedia article output the label or link to the Wikidata object to let the user input a proper label&lt;br /&gt;
				if linkName then return linkName else return &amp;quot;[[:d:&amp;quot; .. id .. &amp;quot;|&amp;quot; .. id .. &amp;quot;]]&amp;quot; end&lt;br /&gt;
			end&lt;br /&gt;
		else&lt;br /&gt;
			return data[parameter]&lt;br /&gt;
		end&lt;br /&gt;
	else&lt;br /&gt;
		return mw.wikibase.getLabel(id) or id&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function printDatavalueTime(data, parameter)&lt;br /&gt;
	-- data fields: time [ISO 8601 time], timezone [int in minutes], before [int], after [int], precision [int], calendarmodel [wikidata URI]&lt;br /&gt;
	--   precision: 0 - billion years, 1 - hundred million years, ..., 6 - millennia, 7 - century, 8 - decade, 9 - year, 10 - month, 11 - day, 12 - hour, 13 - minute, 14 - second&lt;br /&gt;
	--   calendarmodel: e.g. http://www.wikidata.org/entity/Q1985727 for the proleptic Gregorian calendar or http://www.wikidata.org/wiki/Q11184 for the Julian calendar]&lt;br /&gt;
	if parameter then&lt;br /&gt;
		if parameter == &amp;quot;calendarmodel&amp;quot; then data.calendarmodel = mw.ustring.match(data.calendarmodel, &amp;quot;Q%d+&amp;quot;) -- extract entity id from the calendar model URI&lt;br /&gt;
		elseif parameter == &amp;quot;time&amp;quot; then data.time = normalizeDate(data.time) end&lt;br /&gt;
		return data[parameter]&lt;br /&gt;
	else&lt;br /&gt;
		return formatDate(data.time, data.precision, data.timezone)&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function printDatavalueMonolingualText(data, parameter)&lt;br /&gt;
	-- data fields: language [string], text [string]&lt;br /&gt;
	if parameter then&lt;br /&gt;
		return data[parameter]&lt;br /&gt;
	else&lt;br /&gt;
		local result = mw.ustring.gsub(mw.ustring.gsub(i18n.monolingualtext, &amp;quot;%%language&amp;quot;, data[&amp;quot;language&amp;quot;]), &amp;quot;%%text&amp;quot;, data[&amp;quot;text&amp;quot;])&lt;br /&gt;
		return result&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function findClaims(entity, property)&lt;br /&gt;
	if not property or not entity or not entity.claims then return end&lt;br /&gt;
&lt;br /&gt;
	if mw.ustring.match(property, &amp;quot;^P%d+$&amp;quot;) then&lt;br /&gt;
		-- if the property is given by an id (P..) access the claim list by this id&lt;br /&gt;
		return entity.claims[property]&lt;br /&gt;
	else&lt;br /&gt;
		property = mw.wikibase.resolvePropertyId(property)&lt;br /&gt;
		if not property then return end&lt;br /&gt;
&lt;br /&gt;
		return entity.claims[property]&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function getSnakValue(snak, parameter)&lt;br /&gt;
	if snak.snaktype == &amp;quot;value&amp;quot; then&lt;br /&gt;
		-- call the respective snak parser&lt;br /&gt;
		if snak.datavalue.type == &amp;quot;string&amp;quot; then return snak.datavalue.value&lt;br /&gt;
		elseif snak.datavalue.type == &amp;quot;globecoordinate&amp;quot; then return printDatavalueCoordinate(snak.datavalue.value, parameter)&lt;br /&gt;
		elseif snak.datavalue.type == &amp;quot;quantity&amp;quot; then return printDatavalueQuantity(snak.datavalue.value, parameter)&lt;br /&gt;
		elseif snak.datavalue.type == &amp;quot;time&amp;quot; then return printDatavalueTime(snak.datavalue.value, parameter)&lt;br /&gt;
		elseif snak.datavalue.type == &amp;quot;wikibase-entityid&amp;quot; then return printDatavalueEntity(snak.datavalue.value, parameter)&lt;br /&gt;
		elseif snak.datavalue.type == &amp;quot;monolingualtext&amp;quot; then return printDatavalueMonolingualText(snak.datavalue.value, parameter)&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	return mw.wikibase.renderSnak(snak)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function getQualifierSnak(claim, qualifierId)&lt;br /&gt;
	-- a &amp;quot;snak&amp;quot; is Wikidata terminology for a typed key/value pair&lt;br /&gt;
	-- a claim consists of a main snak holding the main information of this claim,&lt;br /&gt;
	-- as well as a list of attribute snaks and a list of references snaks&lt;br /&gt;
	if qualifierId then&lt;br /&gt;
		-- search the attribute snak with the given qualifier as key&lt;br /&gt;
		if claim.qualifiers then&lt;br /&gt;
			local qualifier = claim.qualifiers[qualifierId]&lt;br /&gt;
			if qualifier then return qualifier[1] end&lt;br /&gt;
		end&lt;br /&gt;
		return nil, printError(&amp;quot;qualifier-not-found&amp;quot;)&lt;br /&gt;
	else&lt;br /&gt;
		-- otherwise return the main snak&lt;br /&gt;
		return claim.mainsnak&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function getValueOfClaim(claim, qualifierId, parameter)&lt;br /&gt;
	local error&lt;br /&gt;
	local snak&lt;br /&gt;
	snak, error = getQualifierSnak(claim, qualifierId)&lt;br /&gt;
	if snak then&lt;br /&gt;
		return getSnakValue(snak, parameter)&lt;br /&gt;
	else&lt;br /&gt;
		return nil, error&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function getReferences(frame, claim)&lt;br /&gt;
	local result = &amp;quot;&amp;quot;&lt;br /&gt;
	-- traverse through all references&lt;br /&gt;
	for ref in pairs(claim.references or {}) do&lt;br /&gt;
		local refparts&lt;br /&gt;
		-- traverse through all parts of the current reference&lt;br /&gt;
		for snakkey, snakval in orderedpairs(claim.references[ref].snaks or {}, claim.references[ref][&amp;quot;snaks-order&amp;quot;]) do&lt;br /&gt;
			if refparts then refparts = refparts .. &amp;quot;, &amp;quot; else refparts = &amp;quot;&amp;quot; end&lt;br /&gt;
			-- output the label of the property of the reference part, e.g. &amp;quot;imported from&amp;quot; for P143&lt;br /&gt;
			refparts = refparts .. tostring(mw.wikibase.getLabel(snakkey)) .. &amp;quot;: &amp;quot;&lt;br /&gt;
			-- output all values of this reference part, e.g. &amp;quot;German Wikipedia&amp;quot; and &amp;quot;English Wikipedia&amp;quot; if the referenced claim was imported from both sites&lt;br /&gt;
			for snakidx = 1, #snakval do&lt;br /&gt;
				if snakidx &amp;gt; 1 then refparts = refparts .. &amp;quot;, &amp;quot; end&lt;br /&gt;
				refparts = refparts .. getSnakValue(snakval[snakidx])&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
		if refparts then result = result .. frame:extensionTag(&amp;quot;ref&amp;quot;, refparts) end&lt;br /&gt;
	end&lt;br /&gt;
	return result&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function parseInput(frame)&lt;br /&gt;
	local qid = frame.args.qid&lt;br /&gt;
	if qid and (#qid == 0) then qid = nil end&lt;br /&gt;
	local propertyID = mw.text.trim(frame.args[1] or &amp;quot;&amp;quot;)&lt;br /&gt;
	local input_parm = mw.text.trim(frame.args[2] or &amp;quot;&amp;quot;)&lt;br /&gt;
	if input_parm ~= &amp;quot;FETCH_WIKIDATA&amp;quot; then&lt;br /&gt;
		return false, input_parm, nil, nil&lt;br /&gt;
	end&lt;br /&gt;
	local entity = mw.wikibase.getEntity(qid)&lt;br /&gt;
	local claims&lt;br /&gt;
	if entity and entity.claims then&lt;br /&gt;
		claims = entity.claims[propertyID]&lt;br /&gt;
		if not claims then&lt;br /&gt;
			return false, &amp;quot;&amp;quot;, nil, nil&lt;br /&gt;
		end&lt;br /&gt;
	else&lt;br /&gt;
		return false, &amp;quot;&amp;quot;, nil, nil&lt;br /&gt;
	end&lt;br /&gt;
	return true, entity, claims, propertyID&lt;br /&gt;
end&lt;br /&gt;
local function isType(claims, type)&lt;br /&gt;
	return claims[1] and claims[1].mainsnak.snaktype == &amp;quot;value&amp;quot; and claims[1].mainsnak.datavalue.type == type&lt;br /&gt;
end&lt;br /&gt;
local function getValue(entity, claims, propertyID, delim, labelHook) &lt;br /&gt;
	if labelHook == nil then&lt;br /&gt;
		labelHook = function (qnumber)&lt;br /&gt;
			return nil;&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	if isType(claims, &amp;quot;wikibase-entityid&amp;quot;) then&lt;br /&gt;
		local out = {}&lt;br /&gt;
		for k, v in pairs(claims) do&lt;br /&gt;
			local qnumber = &amp;quot;Q&amp;quot; .. v.mainsnak.datavalue.value[&amp;quot;numeric-id&amp;quot;]&lt;br /&gt;
			local sitelink = mw.wikibase.getSitelink(qnumber)&lt;br /&gt;
			local label = labelHook(qnumber) or mw.wikibase.getLabel(qnumber) or qnumber&lt;br /&gt;
			if sitelink then&lt;br /&gt;
				out[#out + 1] = &amp;quot;[[&amp;quot; .. sitelink .. &amp;quot;|&amp;quot; .. label .. &amp;quot;]]&amp;quot;&lt;br /&gt;
			else&lt;br /&gt;
				out[#out + 1] = &amp;quot;[[:d:&amp;quot; .. qnumber .. &amp;quot;|&amp;quot; .. label .. &amp;quot;]]&amp;lt;abbr title=&#039;&amp;quot; .. i18n[&amp;quot;errors&amp;quot;][&amp;quot;local-article-not-found&amp;quot;] .. &amp;quot;&#039;&amp;gt;[*]&amp;lt;/abbr&amp;gt;&amp;quot;&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
		return table.concat(out, delim)&lt;br /&gt;
	else&lt;br /&gt;
		-- just return best values&lt;br /&gt;
		return entity:formatPropertyValues(propertyID).value&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
------------------------------------------------------------------------------&lt;br /&gt;
-- module global functions&lt;br /&gt;
&lt;br /&gt;
if debug then&lt;br /&gt;
	function p.inspectI18n(frame)&lt;br /&gt;
		local val = i18n&lt;br /&gt;
		for _, key in pairs(frame.args) do&lt;br /&gt;
			key = mw.text.trim(key)&lt;br /&gt;
			val = val[key]&lt;br /&gt;
		end&lt;br /&gt;
		return val&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p.descriptionIn(frame)&lt;br /&gt;
	local langcode = frame.args[1]&lt;br /&gt;
	local id = frame.args[2]&lt;br /&gt;
	-- return description of a Wikidata entity in the given language or the default language of this Wikipedia site&lt;br /&gt;
	return mw.wikibase.getEntity(id):getDescription(langcode or wiki.langcode)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p.labelIn(frame)&lt;br /&gt;
	local langcode = frame.args[1]&lt;br /&gt;
	local id = frame.args[2]&lt;br /&gt;
	-- return label of a Wikidata entity in the given language or the default language of this Wikipedia site&lt;br /&gt;
	return mw.wikibase.getEntity(id):getLabel(langcode or wiki.langcode)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- This is used to get a value, or a comma separated list of them if multiple values exist&lt;br /&gt;
p.getValue = function(frame)&lt;br /&gt;
	local delimdefault = &amp;quot;, &amp;quot; -- **internationalise later**&lt;br /&gt;
	local delim = frame.args.delimiter or &amp;quot;&amp;quot;&lt;br /&gt;
	delim = string.gsub(delim, &#039;&amp;quot;&#039;, &#039;&#039;)&lt;br /&gt;
	if #delim == 0 then&lt;br /&gt;
		delim = delimdefault&lt;br /&gt;
	end&lt;br /&gt;
	local go, errorOrentity, claims, propertyID = parseInput(frame)&lt;br /&gt;
	if not go then&lt;br /&gt;
		return errorOrentity&lt;br /&gt;
	end&lt;br /&gt;
	return getValue(errorOrentity, claims, propertyID, delim)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- Same as above, but uses the short name property for label if available.&lt;br /&gt;
p.getValueShortName = function(frame)&lt;br /&gt;
	local go, errorOrentity, claims, propertyID = parseInput(frame)&lt;br /&gt;
	if not go then&lt;br /&gt;
		return errorOrentity&lt;br /&gt;
	end&lt;br /&gt;
	local entity = errorOrentity&lt;br /&gt;
	-- if wiki-linked value output as link if possible&lt;br /&gt;
	local function labelHook (qnumber)&lt;br /&gt;
		local label&lt;br /&gt;
		local claimEntity = mw.wikibase.getEntity(qnumber)&lt;br /&gt;
		if claimEntity ~= nil then&lt;br /&gt;
			if claimEntity.claims.P1813 then&lt;br /&gt;
				for k2, v2 in pairs(claimEntity.claims.P1813) do&lt;br /&gt;
					if v2.mainsnak.datavalue.value.language == &amp;quot;en&amp;quot; then&lt;br /&gt;
						label = v2.mainsnak.datavalue.value.text&lt;br /&gt;
					end&lt;br /&gt;
				end&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
		if label == nil or label == &amp;quot;&amp;quot; then return nil end&lt;br /&gt;
		return label&lt;br /&gt;
	end&lt;br /&gt;
	return getValue(errorOrentity, claims, propertyID, &amp;quot;, &amp;quot;, labelHook);&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- This is used to get a value, or a comma separated list of them if multiple values exist&lt;br /&gt;
-- from an arbitrary entry by using its QID.&lt;br /&gt;
-- Use : {{#invoke:Wikidata|getValueFromID|&amp;lt;ID&amp;gt;|&amp;lt;Property&amp;gt;|FETCH_WIKIDATA}}&lt;br /&gt;
-- E.g.: {{#invoke:Wikidata|getValueFromID|Q151973|P26|FETCH_WIKIDATA}} - to fetch value of &#039;spouse&#039; (P26) from &#039;Richard Burton&#039; (Q151973)&lt;br /&gt;
-- Please use sparingly - this is an *expensive call*.&lt;br /&gt;
p.getValueFromID = function(frame)&lt;br /&gt;
	local itemID = mw.text.trim(frame.args[1] or &amp;quot;&amp;quot;)&lt;br /&gt;
	local propertyID = mw.text.trim(frame.args[2] or &amp;quot;&amp;quot;)&lt;br /&gt;
	local input_parm = mw.text.trim(frame.args[3] or &amp;quot;&amp;quot;)&lt;br /&gt;
	if input_parm == &amp;quot;FETCH_WIKIDATA&amp;quot; then&lt;br /&gt;
		local entity = mw.wikibase.getEntity(itemID)&lt;br /&gt;
		local claims&lt;br /&gt;
		if entity and entity.claims then&lt;br /&gt;
			claims = entity.claims[propertyID]&lt;br /&gt;
		end&lt;br /&gt;
		if claims then&lt;br /&gt;
			return getValue(entity, claims, propertyID, &amp;quot;, &amp;quot;)&lt;br /&gt;
		else&lt;br /&gt;
			return &amp;quot;&amp;quot;&lt;br /&gt;
		end&lt;br /&gt;
	else&lt;br /&gt;
		return input_parm&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
local function getQualifier(frame, outputHook) &lt;br /&gt;
	local propertyID = mw.text.trim(frame.args[1] or &amp;quot;&amp;quot;)&lt;br /&gt;
	local qualifierID = mw.text.trim(frame.args[2] or &amp;quot;&amp;quot;)&lt;br /&gt;
	local input_parm = mw.text.trim(frame.args[3] or &amp;quot;&amp;quot;)&lt;br /&gt;
	if input_parm == &amp;quot;FETCH_WIKIDATA&amp;quot; then&lt;br /&gt;
		local entity = mw.wikibase.getEntity()&lt;br /&gt;
		if entity.claims[propertyID] ~= nil then&lt;br /&gt;
			local out = {}&lt;br /&gt;
			for k, v in pairs(entity.claims[propertyID]) do&lt;br /&gt;
				for k2, v2 in pairs(v.qualifiers[qualifierID]) do&lt;br /&gt;
					if v2.snaktype == &#039;value&#039; then&lt;br /&gt;
						out[#out + 1] = outputHook(v2);&lt;br /&gt;
					end&lt;br /&gt;
				end&lt;br /&gt;
			end&lt;br /&gt;
			return table.concat(out, &amp;quot;, &amp;quot;), true&lt;br /&gt;
		else&lt;br /&gt;
			return &amp;quot;&amp;quot;, false&lt;br /&gt;
		end&lt;br /&gt;
	else&lt;br /&gt;
		return input_parm, false&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
p.getQualifierValue = function(frame)&lt;br /&gt;
	local function outputValue(value)&lt;br /&gt;
		local qnumber = &amp;quot;Q&amp;quot; .. value.datavalue.value[&amp;quot;numeric-id&amp;quot;]&lt;br /&gt;
		if (mw.wikibase.getSitelink(qnumber)) then&lt;br /&gt;
			return &amp;quot;[[&amp;quot; .. mw.wikibase.getSitelink(qnumber) .. &amp;quot;]]&amp;quot;&lt;br /&gt;
		else&lt;br /&gt;
			return &amp;quot;[[:d:&amp;quot; .. qnumber .. &amp;quot;|&amp;quot; ..qnumber .. &amp;quot;]]&amp;lt;abbr title=&#039;&amp;quot; .. i18n[&amp;quot;errors&amp;quot;][&amp;quot;local-article-not-found&amp;quot;] .. &amp;quot;&#039;&amp;gt;[*]&amp;lt;/abbr&amp;gt;&amp;quot;&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	return (getQualifier(frame, outputValue))&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- This is used to get a value like &#039;male&#039; (for property p21) which won&#039;t be linked and numbers without the thousand separators&lt;br /&gt;
p.getRawValue = function(frame)&lt;br /&gt;
	local go, errorOrentity, claims, propertyID = parseInput(frame)&lt;br /&gt;
	if not go then&lt;br /&gt;
		return errorOrentity&lt;br /&gt;
	end&lt;br /&gt;
	local entity = errorOrentity&lt;br /&gt;
	local result = entity:formatPropertyValues(propertyID, mw.wikibase.entity.claimRanks).value&lt;br /&gt;
	-- if number type: remove thousand separators, bounds and units&lt;br /&gt;
	if isType(claims, &amp;quot;quantity&amp;quot;) then&lt;br /&gt;
		result = mw.ustring.gsub(result, &amp;quot;(%d),(%d)&amp;quot;, &amp;quot;%1%2&amp;quot;)&lt;br /&gt;
		result = mw.ustring.gsub(result, &amp;quot;(%d)±.*&amp;quot;, &amp;quot;%1&amp;quot;)&lt;br /&gt;
	end&lt;br /&gt;
	return result&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- This is used to get the unit name for the numeric value returned by getRawValue&lt;br /&gt;
p.getUnits = function(frame)&lt;br /&gt;
	local go, errorOrentity, claims, propertyID = parseInput(frame)&lt;br /&gt;
	if not go then&lt;br /&gt;
		return errorOrentity&lt;br /&gt;
	end&lt;br /&gt;
	local entity = errorOrentity&lt;br /&gt;
	local result = entity:formatPropertyValues(propertyID, mw.wikibase.entity.claimRanks).value&lt;br /&gt;
	if isType(claims, &amp;quot;quantity&amp;quot;) then&lt;br /&gt;
		result = mw.ustring.sub(result, mw.ustring.find(result, &amp;quot; &amp;quot;)+1, -1)&lt;br /&gt;
	end&lt;br /&gt;
	return result&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- This is used to get the unit&#039;s QID to use with the numeric value returned by getRawValue&lt;br /&gt;
p.getUnitID = function(frame)&lt;br /&gt;
	local go, errorOrentity, claims = parseInput(frame)&lt;br /&gt;
	if not go then&lt;br /&gt;
		return errorOrentity&lt;br /&gt;
	end&lt;br /&gt;
	local entity = errorOrentity&lt;br /&gt;
	local result&lt;br /&gt;
	if isType(claims, &amp;quot;quantity&amp;quot;) then&lt;br /&gt;
		-- get the url for the unit entry on Wikidata:&lt;br /&gt;
		result = claims[1].mainsnak.datavalue.value.unit&lt;br /&gt;
		-- and just reurn the last bit from &amp;quot;Q&amp;quot; to the end (which is the QID):&lt;br /&gt;
		result = mw.ustring.sub(result, mw.ustring.find(result, &amp;quot;Q&amp;quot;), -1)&lt;br /&gt;
	end&lt;br /&gt;
	return result&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
p.getRawQualifierValue = function(frame)&lt;br /&gt;
	local function outputHook(value)&lt;br /&gt;
		if value.datavalue.value[&amp;quot;numeric-id&amp;quot;] then&lt;br /&gt;
			return mw.wikibase.getLabel(&amp;quot;Q&amp;quot; .. value.datavalue.value[&amp;quot;numeric-id&amp;quot;])&lt;br /&gt;
		else&lt;br /&gt;
			return value.datavalue.value&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	local ret, gotData = getQualifier(frame, outputHook)&lt;br /&gt;
	if gotData then&lt;br /&gt;
		ret = string.upper(string.sub(ret, 1, 1)) .. string.sub(ret, 2)&lt;br /&gt;
	end&lt;br /&gt;
	return ret&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- This is used to get a date value for date_of_birth (P569), etc. which won&#039;t be linked&lt;br /&gt;
-- Dates and times are stored in ISO 8601 format (sort of).&lt;br /&gt;
-- At present the local formatDate(date, precision, timezone) function doesn&#039;t handle timezone&lt;br /&gt;
-- So I&#039;ll just supply &amp;quot;Z&amp;quot; in the call to formatDate below:&lt;br /&gt;
p.getDateValue = function(frame)&lt;br /&gt;
	local date_format = mw.text.trim(frame.args[3] or i18n[&amp;quot;datetime&amp;quot;][&amp;quot;default-format&amp;quot;])&lt;br /&gt;
	local date_addon = mw.text.trim(frame.args[4] or i18n[&amp;quot;datetime&amp;quot;][&amp;quot;default-addon&amp;quot;])&lt;br /&gt;
	local go, errorOrentity, claims = parseInput(frame)&lt;br /&gt;
	if not go then&lt;br /&gt;
		return errorOrentity&lt;br /&gt;
	end&lt;br /&gt;
	local entity = errorOrentity&lt;br /&gt;
	local out = {}&lt;br /&gt;
	for k, v in pairs(claims) do&lt;br /&gt;
		if v.mainsnak.datavalue.type == &#039;time&#039; then&lt;br /&gt;
			local timestamp = v.mainsnak.datavalue.value.time&lt;br /&gt;
			local dateprecision = v.mainsnak.datavalue.value.precision&lt;br /&gt;
			-- A year can be stored like this: &amp;quot;+1872-00-00T00:00:00Z&amp;quot;,&lt;br /&gt;
			-- which is processed here as if it were the day before &amp;quot;+1872-01-01T00:00:00Z&amp;quot;,&lt;br /&gt;
			-- and that&#039;s the last day of 1871, so the year is wrong.&lt;br /&gt;
			-- So fix the month 0, day 0 timestamp to become 1 January instead:&lt;br /&gt;
			timestamp = timestamp:gsub(&amp;quot;%-00%-00T&amp;quot;, &amp;quot;-01-01T&amp;quot;)&lt;br /&gt;
			out[#out + 1] = parseDateFull(timestamp, dateprecision, date_format, date_addon)&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	return table.concat(out, &amp;quot;, &amp;quot;)&lt;br /&gt;
end&lt;br /&gt;
p.getQualifierDateValue = function(frame)&lt;br /&gt;
	local date_format = mw.text.trim(frame.args[4] or i18n[&amp;quot;datetime&amp;quot;][&amp;quot;default-format&amp;quot;])&lt;br /&gt;
	local date_addon = mw.text.trim(frame.args[5] or i18n[&amp;quot;datetime&amp;quot;][&amp;quot;default-addon&amp;quot;])&lt;br /&gt;
	local function outputHook(value)&lt;br /&gt;
		local timestamp = value.datavalue.value.time&lt;br /&gt;
		return parseDateValue(timestamp, date_format, date_addon)&lt;br /&gt;
	end&lt;br /&gt;
	return (getQualifier(frame, outputHook))&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- This is used to fetch all of the images with a particular property, e.g. image (P18), Gene Atlas Image (P692), etc.&lt;br /&gt;
-- Parameters are | propertyID | value / FETCH_WIKIDATA / nil | separator (default=space) | size (default=frameless)&lt;br /&gt;
-- It will return a standard wiki-markup [[File:Filename | size]] for each image with a selectable size and separator (which may be html)&lt;br /&gt;
-- e.g. {{#invoke:Wikidata|getImages|P18|FETCH_WIKIDATA}}&lt;br /&gt;
-- e.g. {{#invoke:Wikidata|getImages|P18|FETCH_WIKIDATA|&amp;lt;br&amp;gt;|250px}}&lt;br /&gt;
-- If a property is chosen that is not of type &amp;quot;commonsMedia&amp;quot;, it will return empty text.&lt;br /&gt;
p.getImages = function(frame)&lt;br /&gt;
	local sep = mw.text.trim(frame.args[3] or &amp;quot; &amp;quot;)&lt;br /&gt;
	local imgsize = mw.text.trim(frame.args[4] or &amp;quot;frameless&amp;quot;)&lt;br /&gt;
	local go, errorOrentity, claims = parseInput(frame)&lt;br /&gt;
	if not go then&lt;br /&gt;
		return errorOrentity&lt;br /&gt;
	end&lt;br /&gt;
	local entity = errorOrentity&lt;br /&gt;
	if (claims[1] and claims[1].mainsnak.datatype == &amp;quot;commonsMedia&amp;quot;) then&lt;br /&gt;
		local out = {}&lt;br /&gt;
		for k, v in pairs(claims) do&lt;br /&gt;
			local filename = v.mainsnak.datavalue.value&lt;br /&gt;
			out[#out + 1] = &amp;quot;[[File:&amp;quot; .. filename .. &amp;quot;|&amp;quot; .. imgsize .. &amp;quot;]]&amp;quot;&lt;br /&gt;
		end&lt;br /&gt;
		return table.concat(out, sep)&lt;br /&gt;
	else&lt;br /&gt;
		return &amp;quot;&amp;quot;&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- This is used to get the TA98 (Terminologia Anatomica first edition 1998) values like &#039;A01.1.00.005&#039; (property P1323)&lt;br /&gt;
-- which are then linked to http://www.unifr.ch/ifaa/Public/EntryPage/TA98%20Tree/Entity%20TA98%20EN/01.1.00.005%20Entity%20TA98%20EN.htm&lt;br /&gt;
-- uses the newer mw.wikibase calls instead of directly using the snaks&lt;br /&gt;
-- formatPropertyValues returns a table with the P1323 values concatenated with &amp;quot;, &amp;quot; so we have to split them out into a table in order to construct the return string&lt;br /&gt;
p.getTAValue = function(frame)&lt;br /&gt;
	local ent = mw.wikibase.getEntity()&lt;br /&gt;
	local props = ent:formatPropertyValues(&#039;P1323&#039;)&lt;br /&gt;
	local out = {}&lt;br /&gt;
	local t = {}&lt;br /&gt;
	for k, v in pairs(props) do&lt;br /&gt;
		if k == &#039;value&#039; then&lt;br /&gt;
			t = mw.text.split( v, &amp;quot;, &amp;quot;)&lt;br /&gt;
			for k2, v2 in pairs(t) do&lt;br /&gt;
				out[#out + 1] = &amp;quot;[http://www.unifr.ch/ifaa/Public/EntryPage/TA98%20Tree/Entity%20TA98%20EN/&amp;quot; .. string.sub(v2, 2) .. &amp;quot;%20Entity%20TA98%20EN.htm &amp;quot; .. v2 .. &amp;quot;]&amp;quot;&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	local ret = table.concat(out, &amp;quot;&amp;lt;br&amp;gt; &amp;quot;)&lt;br /&gt;
	if #ret == 0 then&lt;br /&gt;
		ret = &amp;quot;Invalid TA&amp;quot;&lt;br /&gt;
	end&lt;br /&gt;
	return ret&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--[[&lt;br /&gt;
This is used to return an image legend from Wikidata&lt;br /&gt;
image is property P18&lt;br /&gt;
image legend is property P2096&lt;br /&gt;
&lt;br /&gt;
Call as {{#invoke:Wikidata |getImageLegend | &amp;lt;PARAMETER&amp;gt; | lang=&amp;lt;ISO-639code&amp;gt; |id=&amp;lt;QID&amp;gt;}}&lt;br /&gt;
Returns PARAMETER, unless it is equal to &amp;quot;FETCH_WIKIDATA&amp;quot;, from Item QID (expensive call)&lt;br /&gt;
If QID is omitted or blank, the current article is used (not an expensive call)&lt;br /&gt;
If lang is omitted, it uses the local wiki language, otherwise it uses the provided ISO-639 language code&lt;br /&gt;
ISO-639: https://docs.oracle.com/cd/E13214_01/wli/docs92/xref/xqisocodes.html#wp1252447&lt;br /&gt;
&lt;br /&gt;
Ranks are: &#039;preferred&#039; &amp;gt; &#039;normal&#039;&lt;br /&gt;
This returns the label from the first image with &#039;preferred&#039; rank&lt;br /&gt;
Or the label from the first image with &#039;normal&#039; rank if preferred returns nothing&lt;br /&gt;
Ranks: https://www.mediawiki.org/wiki/Extension:Wikibase_Client/Lua&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
p.getImageLegend = function(frame)&lt;br /&gt;
	-- look for named parameter id; if it&#039;s blank make it nil&lt;br /&gt;
	local id = frame.args.id&lt;br /&gt;
	if id and (#id == 0) then&lt;br /&gt;
		id = nil&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- look for named parameter lang&lt;br /&gt;
	-- it should contain a two-character ISO-639 language code&lt;br /&gt;
	-- if it&#039;s blank fetch the language of the local wiki&lt;br /&gt;
	local lang = frame.args.lang&lt;br /&gt;
	if (not lang) or (#lang &amp;lt; 2) then&lt;br /&gt;
		lang = mw.language.getContentLanguage().code&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- first unnamed parameter is the local parameter, if supplied&lt;br /&gt;
	local input_parm = mw.text.trim(frame.args[1] or &amp;quot;&amp;quot;)&lt;br /&gt;
	if input_parm == &amp;quot;FETCH_WIKIDATA&amp;quot; then&lt;br /&gt;
		local ent = mw.wikibase.getEntity(id)&lt;br /&gt;
		local imgs&lt;br /&gt;
		if ent and ent.claims then&lt;br /&gt;
			imgs = ent.claims.P18&lt;br /&gt;
		end&lt;br /&gt;
		local imglbl&lt;br /&gt;
		if imgs then&lt;br /&gt;
			-- look for an image with &#039;preferred&#039; rank&lt;br /&gt;
			for k1, v1 in pairs(imgs) do&lt;br /&gt;
				if v1.rank == &amp;quot;preferred&amp;quot; and v1.qualifiers and v1.qualifiers.P2096 then&lt;br /&gt;
					local imglbls = v1.qualifiers.P2096&lt;br /&gt;
					for k2, v2 in pairs(imglbls) do&lt;br /&gt;
						if v2.datavalue.value.language == lang then&lt;br /&gt;
							imglbl = v2.datavalue.value.text&lt;br /&gt;
							break&lt;br /&gt;
						end&lt;br /&gt;
					end&lt;br /&gt;
				end&lt;br /&gt;
			end&lt;br /&gt;
			-- if we don&#039;t find one, look for an image with &#039;normal&#039; rank&lt;br /&gt;
			if (not imglbl) then&lt;br /&gt;
				for k1, v1 in pairs(imgs) do&lt;br /&gt;
					if v1.rank == &amp;quot;normal&amp;quot; and v1.qualifiers and v1.qualifiers.P2096 then&lt;br /&gt;
						local imglbls = v1.qualifiers.P2096&lt;br /&gt;
						for k2, v2 in pairs(imglbls) do&lt;br /&gt;
							if v2.datavalue.value.language == lang then&lt;br /&gt;
								imglbl = v2.datavalue.value.text&lt;br /&gt;
								break&lt;br /&gt;
							end&lt;br /&gt;
						end&lt;br /&gt;
					end&lt;br /&gt;
				end&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
		return imglbl&lt;br /&gt;
	else&lt;br /&gt;
		return input_parm&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- This is used to get the QIDs of all of the values of a property, as a comma separated list if multiple values exist&lt;br /&gt;
-- Usage: {{#invoke:Wikidata |getPropertyIDs |&amp;lt;PropertyID&amp;gt; |FETCH_WIKIDATA}}&lt;br /&gt;
-- Usage: {{#invoke:Wikidata |getPropertyIDs |&amp;lt;PropertyID&amp;gt; |&amp;lt;InputParameter&amp;gt; |qid=&amp;lt;QID&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
p.getPropertyIDs = function(frame)&lt;br /&gt;
	local go, errorOrentity, propclaims = parseInput(frame)&lt;br /&gt;
	if not go then&lt;br /&gt;
		return errorOrentity&lt;br /&gt;
	end&lt;br /&gt;
	local entity = errorOrentity&lt;br /&gt;
	-- if wiki-linked value collect the QID in a table&lt;br /&gt;
	if (propclaims[1] and propclaims[1].mainsnak.snaktype == &amp;quot;value&amp;quot; and propclaims[1].mainsnak.datavalue.type == &amp;quot;wikibase-entityid&amp;quot;) then&lt;br /&gt;
		local out = {}&lt;br /&gt;
		for k, v in pairs(propclaims) do&lt;br /&gt;
			out[#out + 1] = &amp;quot;Q&amp;quot; .. v.mainsnak.datavalue.value[&amp;quot;numeric-id&amp;quot;]&lt;br /&gt;
		end&lt;br /&gt;
		return table.concat(out, &amp;quot;, &amp;quot;)&lt;br /&gt;
	else&lt;br /&gt;
		-- not a wikibase-entityid, so return empty&lt;br /&gt;
		return &amp;quot;&amp;quot;&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- returns the page id (Q...) of the current page or nothing of the page is not connected to Wikidata&lt;br /&gt;
function p.pageId(frame)&lt;br /&gt;
	return mw.wikibase.getEntityIdForCurrentPage()&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p.claim(frame)&lt;br /&gt;
	local property = frame.args[1] or &amp;quot;&amp;quot;&lt;br /&gt;
	local id = frame.args[&amp;quot;id&amp;quot;]&lt;br /&gt;
	local qualifierId = frame.args[&amp;quot;qualifier&amp;quot;]&lt;br /&gt;
	local parameter = frame.args[&amp;quot;parameter&amp;quot;]&lt;br /&gt;
	local list = frame.args[&amp;quot;list&amp;quot;]&lt;br /&gt;
	local references = frame.args[&amp;quot;references&amp;quot;]&lt;br /&gt;
	local showerrors = frame.args[&amp;quot;showerrors&amp;quot;]&lt;br /&gt;
	local default = frame.args[&amp;quot;default&amp;quot;]&lt;br /&gt;
	if default then showerrors = nil end&lt;br /&gt;
&lt;br /&gt;
	-- get wikidata entity&lt;br /&gt;
	local entity = mw.wikibase.getEntity(id)&lt;br /&gt;
	if not entity then&lt;br /&gt;
		if showerrors then return printError(&amp;quot;entity-not-found&amp;quot;) else return default end&lt;br /&gt;
	end&lt;br /&gt;
	-- fetch the first claim of satisfying the given property&lt;br /&gt;
	local claims = findClaims(entity, property)&lt;br /&gt;
	if not claims or not claims[1] then&lt;br /&gt;
		if showerrors then return printError(&amp;quot;property-not-found&amp;quot;) else return default end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- get initial sort indices&lt;br /&gt;
	local sortindices = {}&lt;br /&gt;
	for idx in pairs(claims) do&lt;br /&gt;
		sortindices[#sortindices + 1] = idx&lt;br /&gt;
	end&lt;br /&gt;
	-- sort by claim rank&lt;br /&gt;
	local comparator = function(a, b)&lt;br /&gt;
		local rankmap = { deprecated = 2, normal = 1, preferred = 0 }&lt;br /&gt;
		local ranka = rankmap[claims[a].rank or &amp;quot;normal&amp;quot;] .. string.format(&amp;quot;%08d&amp;quot;, a)&lt;br /&gt;
		local rankb = rankmap[claims[b].rank or &amp;quot;normal&amp;quot;] .. string.format(&amp;quot;%08d&amp;quot;, b)&lt;br /&gt;
		return ranka &amp;lt; rankb&lt;br /&gt;
	end&lt;br /&gt;
	table.sort(sortindices, comparator)&lt;br /&gt;
&lt;br /&gt;
	local result&lt;br /&gt;
	local error&lt;br /&gt;
	if list then&lt;br /&gt;
		local value&lt;br /&gt;
		-- iterate over all elements and return their value (if existing)&lt;br /&gt;
		result = {}&lt;br /&gt;
		for idx in pairs(claims) do&lt;br /&gt;
			local claim = claims[sortindices[idx]]&lt;br /&gt;
			value, error = getValueOfClaim(claim, qualifierId, parameter)&lt;br /&gt;
			if not value and showerrors then value = error end&lt;br /&gt;
			if value and references then value = value .. getReferences(frame, claim) end&lt;br /&gt;
			result[#result + 1] = value&lt;br /&gt;
		end&lt;br /&gt;
		result = table.concat(result, list)&lt;br /&gt;
	else&lt;br /&gt;
		-- return first element&lt;br /&gt;
		local claim = claims[sortindices[1]]&lt;br /&gt;
		result, error = getValueOfClaim(claim, qualifierId, parameter)&lt;br /&gt;
		if result and references then result = result .. getReferences(frame, claim) end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	if result then return result else&lt;br /&gt;
		if showerrors then return error else return default end&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- look into entity object&lt;br /&gt;
function p.ViewSomething(frame)&lt;br /&gt;
	local f = (frame.args[1] or frame.args.id) and frame or frame:getParent()&lt;br /&gt;
	local id = f.args.id&lt;br /&gt;
	if id and (#id == 0) then&lt;br /&gt;
		id = nil&lt;br /&gt;
	end&lt;br /&gt;
	local data = mw.wikibase.getEntity(id)&lt;br /&gt;
	if not data then&lt;br /&gt;
		return nil&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	local i = 1&lt;br /&gt;
	while true do&lt;br /&gt;
		local index = f.args[i]&lt;br /&gt;
		if not index then&lt;br /&gt;
			if type(data) == &amp;quot;table&amp;quot; then&lt;br /&gt;
				return mw.text.jsonEncode(data, mw.text.JSON_PRESERVE_KEYS + mw.text.JSON_PRETTY)&lt;br /&gt;
			else&lt;br /&gt;
				return tostring(data)&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
&lt;br /&gt;
		data = data[index] or data[tonumber(index)]&lt;br /&gt;
		if not data then&lt;br /&gt;
			return&lt;br /&gt;
		end&lt;br /&gt;
&lt;br /&gt;
		i = i + 1&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- getting sitelink of a given wiki&lt;br /&gt;
-- get sitelink of current item if qid not supplied&lt;br /&gt;
function p.getSiteLink(frame)&lt;br /&gt;
	local qid = frame.args.qid&lt;br /&gt;
	if qid == &amp;quot;&amp;quot; then qid = nil end&lt;br /&gt;
	local f = mw.text.trim( frame.args[1] or &amp;quot;&amp;quot;)&lt;br /&gt;
	local entity = mw.wikibase.getEntity(qid)&lt;br /&gt;
	if not entity then&lt;br /&gt;
		return&lt;br /&gt;
	end&lt;br /&gt;
	local link = entity:getSitelink( f )&lt;br /&gt;
	if not link then&lt;br /&gt;
		return&lt;br /&gt;
	end&lt;br /&gt;
	return link&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p.Dump(frame)&lt;br /&gt;
	local f = (frame.args[1] or frame.args.id) and frame or frame:getParent()&lt;br /&gt;
	local data = mw.wikibase.getEntity(f.args.id)&lt;br /&gt;
	if not data then&lt;br /&gt;
		return i18n.warnDump&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	local i = 1&lt;br /&gt;
	while true do&lt;br /&gt;
		local index = f.args[i]&lt;br /&gt;
		if not index then&lt;br /&gt;
			return &amp;quot;&amp;lt;pre&amp;gt;&amp;quot;..mw.dumpObject(data)..&amp;quot;&amp;lt;/pre&amp;gt;&amp;quot;.. i18n.warnDump&lt;br /&gt;
		end&lt;br /&gt;
&lt;br /&gt;
		data = data[index] or data[tonumber(index)]&lt;br /&gt;
		if not data then&lt;br /&gt;
			return i18n.warnDump&lt;br /&gt;
		end&lt;br /&gt;
&lt;br /&gt;
		i = i + 1&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
return p&lt;/div&gt;</summary>
		<author><name>Marie</name></author>
	</entry>
	<entry>
		<id>http://project-au.w.kmwc.org/index.php?title=Tetropsid&amp;diff=2081</id>
		<title>Tetropsid</title>
		<link rel="alternate" type="text/html" href="http://project-au.w.kmwc.org/index.php?title=Tetropsid&amp;diff=2081"/>
		<updated>2026-01-16T09:59:19Z</updated>

		<summary type="html">&lt;p&gt;Marie: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Taxobox&lt;br /&gt;
| name               = Tetropsid&lt;br /&gt;
| image              = Tetropsid scale.png&lt;br /&gt;
| image_upright      =&lt;br /&gt;
| image_alt          = &lt;br /&gt;
| image_caption      = Diagram showing the side of a Tetropsid, with a Human for comparison&lt;br /&gt;
| status             = LC&lt;br /&gt;
| colour_as          = Animalia&lt;br /&gt;
| regnum             = ?&lt;br /&gt;
| phylum             = ?&lt;br /&gt;
| classis            = ?&lt;br /&gt;
| superordo          = ?&lt;br /&gt;
| ordo               = ?&lt;br /&gt;
| superfamilia       = ?&lt;br /&gt;
| familia            = Tetropsidae&lt;br /&gt;
| genus              = Tetropsid&lt;br /&gt;
| species            = &#039;&#039;&#039;T. kontupsos&#039;&#039;&#039;&lt;br /&gt;
| binomial           = &#039;&#039;Tetropsid kontupsos&#039;&#039;&lt;br /&gt;
| binomial_authority = &lt;br /&gt;
| range_map          = &amp;lt;!--optional map—also range map2, 3 or 4 --&amp;gt;&lt;br /&gt;
| range_map_upright    = &lt;br /&gt;
| range map_alt      = &lt;br /&gt;
| range_map_caption  = &lt;br /&gt;
| status_system      = IUCN3.1&lt;br /&gt;
| &amp;lt;!--or 115 other parameters--&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Tetropsids&#039;&#039;&#039; are a sophont species within the [[Settled Systems]], originating from the planet [[Heéqʼb]]. They are short and shelled creatures with quadrilateral symmetry across the body.&lt;br /&gt;
&lt;br /&gt;
==Etymology and name==&lt;br /&gt;
The name &#039;&#039;Tetropsid&#039;&#039; is a contraction meaning “four eyed” or “four faced,” while &#039;&#039;kontupsos&#039;&#039; is a contracted form meaning “short height.” The native name for Tetropsids in [[Totuqi language|Totuqi]] is &#039;&#039;ʼḍhrò&#039;&#039;, and &#039;&#039;X&#039;&#039; in [[Heeqid language|Heeqid]].&lt;br /&gt;
&lt;br /&gt;
[[Category:Biology]][[Category:Species]][[Category:Sophonts]]&lt;/div&gt;</summary>
		<author><name>Marie</name></author>
	</entry>
	<entry>
		<id>http://project-au.w.kmwc.org/index.php?title=Eternal_Rulership_of_the_Four_Fortresses&amp;diff=2078</id>
		<title>Eternal Rulership of the Four Fortresses</title>
		<link rel="alternate" type="text/html" href="http://project-au.w.kmwc.org/index.php?title=Eternal_Rulership_of_the_Four_Fortresses&amp;diff=2078"/>
		<updated>2026-01-15T17:44:27Z</updated>

		<summary type="html">&lt;p&gt;Marie: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Infobox country&lt;br /&gt;
|conventional_long_name= Eternal Rulership of the Four Fortresses&lt;br /&gt;
|native_name= &#039;&#039;Ḍroó sä Ḍhaamdò Wà Shuòʼtä̀d sä Huág&#039;&#039;&lt;br /&gt;
|common_name=&lt;br /&gt;
|image_symbol= ERFF Crest.png&lt;br /&gt;
|symbol_type= Symbol&lt;br /&gt;
|symbol=&lt;br /&gt;
|capital_type= Capital world&lt;br /&gt;
|capital= [[ʼṬotuq]]&lt;br /&gt;
|largest_settlement_type = planet &lt;br /&gt;
|largest_settlement = [[Heéqʼb]]&lt;br /&gt;
|official_languages= [[Totuqi language|Totuqi]]&amp;lt;br&amp;gt;[[Heeqid language|Heeqid]]&lt;br /&gt;
|government_type= ?&lt;br /&gt;
|demonym= Dhro&amp;lt;br&amp;gt;Tetropsid&lt;br /&gt;
|upper_house=&lt;br /&gt;
|lower_house=&lt;br /&gt;
|currency=&lt;br /&gt;
}}&lt;/div&gt;</summary>
		<author><name>Marie</name></author>
	</entry>
	<entry>
		<id>http://project-au.w.kmwc.org/index.php?title=Tetropsid&amp;diff=2077</id>
		<title>Tetropsid</title>
		<link rel="alternate" type="text/html" href="http://project-au.w.kmwc.org/index.php?title=Tetropsid&amp;diff=2077"/>
		<updated>2026-01-15T17:38:13Z</updated>

		<summary type="html">&lt;p&gt;Marie: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Taxobox&lt;br /&gt;
| name               = Tetropsid&lt;br /&gt;
| image              = Tetropsid scale.png&lt;br /&gt;
| image_upright      =&lt;br /&gt;
| image_alt          = &lt;br /&gt;
| image_caption      = Diagram showing the side of a Tetropsid, with a Human for comparison&lt;br /&gt;
| status             = LC&lt;br /&gt;
| colour_as          = Animalia&lt;br /&gt;
| regnum             = ?&lt;br /&gt;
| phylum             = ?&lt;br /&gt;
| classis            = ?&lt;br /&gt;
| superordo          = ?&lt;br /&gt;
| ordo               = ?&lt;br /&gt;
| superfamilia       = ?&lt;br /&gt;
| familia            = Tetropsidae&lt;br /&gt;
| genus              = Tetropsid&lt;br /&gt;
| species            = &#039;&#039;&#039;T. kontupsos&#039;&#039;&#039;&lt;br /&gt;
| binomial           = &#039;&#039;Tetropsid kontupsos&#039;&#039;&lt;br /&gt;
| binomial_authority = &lt;br /&gt;
| range_map          = &amp;lt;!--optional map—also range map2, 3 or 4 --&amp;gt;&lt;br /&gt;
| range_map_upright    = &lt;br /&gt;
| range map_alt      = &lt;br /&gt;
| range_map_caption  = &lt;br /&gt;
| &amp;lt;!--or 115 other parameters--&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Tetropsids&#039;&#039;&#039; are a sophont species within the [[Settled Systems]], originating from the planet [[Heéqʼb]]. They are short and shelled creatures with quadrilateral symmetry across the body.&lt;br /&gt;
&lt;br /&gt;
==Etymology and name==&lt;br /&gt;
The name &#039;&#039;Tetropsid&#039;&#039; is a contraction meaning “four eyed” or “four faced,” while &#039;&#039;kontupsos&#039;&#039; is a contracted form meaning “short height.” The native name for Tetropsids in [[Totuqi language|Totuqi]] is &#039;&#039;ʼḍhrò&#039;&#039;, and &#039;&#039;X&#039;&#039; in [[Heeqid language|Heeqid]].&lt;br /&gt;
&lt;br /&gt;
[[Category:Biology]][[Category:Species]][[Category:Sophonts]]&lt;/div&gt;</summary>
		<author><name>Marie</name></author>
	</entry>
	<entry>
		<id>http://project-au.w.kmwc.org/index.php?title=Tetropsid&amp;diff=2076</id>
		<title>Tetropsid</title>
		<link rel="alternate" type="text/html" href="http://project-au.w.kmwc.org/index.php?title=Tetropsid&amp;diff=2076"/>
		<updated>2026-01-15T17:30:02Z</updated>

		<summary type="html">&lt;p&gt;Marie: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Taxobox&lt;br /&gt;
| name               = Tetropsid&lt;br /&gt;
| image              = Tetropsid scale.png&lt;br /&gt;
| image_upright      =&lt;br /&gt;
| image_alt          = &lt;br /&gt;
| image_caption      = Diagram showing the side of a Tetropsid, with a Human for comparison&lt;br /&gt;
| status             = LC&lt;br /&gt;
| colour_as          = Animalia&lt;br /&gt;
| regnum             = ?&lt;br /&gt;
| phylum             = ?&lt;br /&gt;
| classis            = ?&lt;br /&gt;
| superordo          = ?&lt;br /&gt;
| ordo               = ?&lt;br /&gt;
| superfamilia       = ?&lt;br /&gt;
| familia            = Tetropsidae&lt;br /&gt;
| genus              = Tetropsid&lt;br /&gt;
| species            = &#039;&#039;&#039;T. kontsupsos&#039;&#039;&#039;&lt;br /&gt;
| binomial           = &#039;&#039;Tetropsid kontupsos&#039;&#039;&lt;br /&gt;
| binomial_authority = &lt;br /&gt;
| range_map          = &amp;lt;!--optional map—also range map2, 3 or 4 --&amp;gt;&lt;br /&gt;
| range_map_upright    = &lt;br /&gt;
| range map_alt      = &lt;br /&gt;
| range_map_caption  = &lt;br /&gt;
| &amp;lt;!--or 115 other parameters--&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Tetropsids&#039;&#039;&#039; are a sophont species within the [[Settled Systems]], originating from the planet [[Heéqʼb]]. They are short and shelled creatures with quadrilateral symmetry across the body.&lt;br /&gt;
&lt;br /&gt;
[[Category:Biology]][[Category:Species]][[Category:Sophonts]]&lt;/div&gt;</summary>
		<author><name>Marie</name></author>
	</entry>
	<entry>
		<id>http://project-au.w.kmwc.org/index.php?title=Tetropsid&amp;diff=2075</id>
		<title>Tetropsid</title>
		<link rel="alternate" type="text/html" href="http://project-au.w.kmwc.org/index.php?title=Tetropsid&amp;diff=2075"/>
		<updated>2026-01-15T17:29:30Z</updated>

		<summary type="html">&lt;p&gt;Marie: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Taxobox&lt;br /&gt;
| name               = Tetropsid&lt;br /&gt;
| image              = Tetropsid scale.png&lt;br /&gt;
| image_upright      =&lt;br /&gt;
| image_alt          = &lt;br /&gt;
| image_caption      = Diagram showing the side of a Tetropsid, with a Human for comparison&lt;br /&gt;
| status             = LC&lt;br /&gt;
| colour_as          = Animalia&lt;br /&gt;
| regnum             = ?&lt;br /&gt;
| phylum             = ?&lt;br /&gt;
| classis            = ?&lt;br /&gt;
| superordo          = ?&lt;br /&gt;
| ordo               = ?&lt;br /&gt;
| superfamilia       = ?&lt;br /&gt;
| familia            = &#039;&#039;&#039;Tetropsidae&#039;&#039;&#039;&lt;br /&gt;
| genus              = &#039;&#039;&#039;Tetropsid&#039;&#039;&#039;&lt;br /&gt;
| species            = &#039;&#039;&#039;T. kontsupsos&#039;&#039;&#039;&lt;br /&gt;
| binomial           = &#039;&#039;Tetropsid kontupsos&#039;&#039;&lt;br /&gt;
| binomial_authority = &lt;br /&gt;
| range_map          = &amp;lt;!--optional map—also range map2, 3 or 4 --&amp;gt;&lt;br /&gt;
| range_map_upright    = &lt;br /&gt;
| range map_alt      = &lt;br /&gt;
| range_map_caption  = &lt;br /&gt;
| &amp;lt;!--or 115 other parameters--&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Tetropsids&#039;&#039;&#039; are a sophont species within the [[Settled Systems]], originating from the planet [[Heéqʼb]]. They are short and shelled creatures with quadrilateral symmetry across the body.&lt;br /&gt;
&lt;br /&gt;
[[Category:Biology]][[Category:Species]][[Category:Sophonts]]&lt;/div&gt;</summary>
		<author><name>Marie</name></author>
	</entry>
	<entry>
		<id>http://project-au.w.kmwc.org/index.php?title=Tetropsid&amp;diff=2074</id>
		<title>Tetropsid</title>
		<link rel="alternate" type="text/html" href="http://project-au.w.kmwc.org/index.php?title=Tetropsid&amp;diff=2074"/>
		<updated>2026-01-15T17:24:28Z</updated>

		<summary type="html">&lt;p&gt;Marie: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Taxobox&lt;br /&gt;
| name               = Tetropsid&lt;br /&gt;
| image              = Tetropsid scale.png&lt;br /&gt;
| image_upright      =&lt;br /&gt;
| image_alt          = &lt;br /&gt;
| image_caption      = Diagram showing the side of a Tetropsid, with a Human for comparison&lt;br /&gt;
| status             = LC&lt;br /&gt;
| colour_as          = Animalia&lt;br /&gt;
| regnum             = ?&lt;br /&gt;
| phylum             = ?&lt;br /&gt;
| classis            = ?&lt;br /&gt;
| superordo          = ?&lt;br /&gt;
| ordo               = ?&lt;br /&gt;
| superfamilia       = ?&lt;br /&gt;
| familia            = ?&lt;br /&gt;
| genus              = ?&lt;br /&gt;
| species            = &#039;&#039;&#039;?&#039;&#039;&#039;&lt;br /&gt;
| binomial           = &#039;&#039;? ?&#039;&#039;&lt;br /&gt;
| binomial_authority = &lt;br /&gt;
| range_map          = &amp;lt;!--optional map—also range map2, 3 or 4 --&amp;gt;&lt;br /&gt;
| range_map_upright    = &lt;br /&gt;
| range map_alt      = &lt;br /&gt;
| range_map_caption  = &lt;br /&gt;
| &amp;lt;!--or 115 other parameters--&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Tetropsids&#039;&#039;&#039; are a sophont species within the [[Settled Systems]], originating from the planet [[Heéqʼb]]. They are short and shelled creatures with quadrilateral symmetry across the body.&lt;br /&gt;
&lt;br /&gt;
[[Category:Biology]][[Category:Species]][[Category:Sophonts]]&lt;/div&gt;</summary>
		<author><name>Marie</name></author>
	</entry>
	<entry>
		<id>http://project-au.w.kmwc.org/index.php?title=Eternal_Rulership_of_the_Four_Fortresses&amp;diff=2072</id>
		<title>Eternal Rulership of the Four Fortresses</title>
		<link rel="alternate" type="text/html" href="http://project-au.w.kmwc.org/index.php?title=Eternal_Rulership_of_the_Four_Fortresses&amp;diff=2072"/>
		<updated>2026-01-13T19:43:58Z</updated>

		<summary type="html">&lt;p&gt;Marie: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Infobox country&lt;br /&gt;
|conventional_long_name= Eternal Rulership of the Four Fortresses&lt;br /&gt;
|native_name= &#039;&#039;Ḍroó sä Ḍhaamdò Wà Shuòʼtä̀d sä Huág&#039;&#039;&lt;br /&gt;
|common_name=&lt;br /&gt;
|image_symbol= ERFF Crest.png&lt;br /&gt;
|symbol_type= Symbol&lt;br /&gt;
|symbol=&lt;br /&gt;
|capital_type= Capital world&lt;br /&gt;
|capital= [[ʼṬotuq]]&lt;br /&gt;
|largest_settlement_type = planet &lt;br /&gt;
|largest_settlement = [[Heéqʼb]]&lt;br /&gt;
|official_languages= ?&lt;br /&gt;
|government_type= ?&lt;br /&gt;
|demonym= Dhro&amp;lt;br&amp;gt;Tetropsid&lt;br /&gt;
|upper_house=&lt;br /&gt;
|lower_house=&lt;br /&gt;
|currency=&lt;br /&gt;
}}&lt;/div&gt;</summary>
		<author><name>Marie</name></author>
	</entry>
	<entry>
		<id>http://project-au.w.kmwc.org/index.php?title=Eternal_Rulership_of_the_Four_Fortresses&amp;diff=2071</id>
		<title>Eternal Rulership of the Four Fortresses</title>
		<link rel="alternate" type="text/html" href="http://project-au.w.kmwc.org/index.php?title=Eternal_Rulership_of_the_Four_Fortresses&amp;diff=2071"/>
		<updated>2026-01-13T14:55:21Z</updated>

		<summary type="html">&lt;p&gt;Marie: Created page with &amp;quot;{{Infobox country |conventional_long_name= Eternal Rulership of the Four Fortresses |native_name= ? |common_name= |image_symbol= ERFF Crest.png |symbol_type= Symbol |symbol= |capital_type= Capital world |capital= ʼṬotuq |largest_settlement_type = planet  |largest_settlement = Heéqʼb |official_languages= ? |government_type= ? |demonym= Dhro&amp;lt;br&amp;gt;Tetropsid |upper_house= |lower_house= |currency= }}&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Infobox country&lt;br /&gt;
|conventional_long_name= Eternal Rulership of the Four Fortresses&lt;br /&gt;
|native_name= ?&lt;br /&gt;
|common_name=&lt;br /&gt;
|image_symbol= ERFF Crest.png&lt;br /&gt;
|symbol_type= Symbol&lt;br /&gt;
|symbol=&lt;br /&gt;
|capital_type= Capital world&lt;br /&gt;
|capital= [[ʼṬotuq]]&lt;br /&gt;
|largest_settlement_type = planet &lt;br /&gt;
|largest_settlement = [[Heéqʼb]]&lt;br /&gt;
|official_languages= ?&lt;br /&gt;
|government_type= ?&lt;br /&gt;
|demonym= Dhro&amp;lt;br&amp;gt;Tetropsid&lt;br /&gt;
|upper_house=&lt;br /&gt;
|lower_house=&lt;br /&gt;
|currency=&lt;br /&gt;
}}&lt;/div&gt;</summary>
		<author><name>Marie</name></author>
	</entry>
	<entry>
		<id>http://project-au.w.kmwc.org/index.php?title=File:ERFF_Crest.png&amp;diff=2070</id>
		<title>File:ERFF Crest.png</title>
		<link rel="alternate" type="text/html" href="http://project-au.w.kmwc.org/index.php?title=File:ERFF_Crest.png&amp;diff=2070"/>
		<updated>2026-01-13T14:47:26Z</updated>

		<summary type="html">&lt;p&gt;Marie: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Marie</name></author>
	</entry>
	<entry>
		<id>http://project-au.w.kmwc.org/index.php?title=Main_Page&amp;diff=2069</id>
		<title>Main Page</title>
		<link rel="alternate" type="text/html" href="http://project-au.w.kmwc.org/index.php?title=Main_Page&amp;diff=2069"/>
		<updated>2026-01-13T14:46:53Z</updated>

		<summary type="html">&lt;p&gt;Marie: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Front/banner}}__NOTOC__&lt;br /&gt;
{| class=&amp;quot;mp_content&amp;quot;&lt;br /&gt;
|class=&amp;quot;mp_left mp_box&amp;quot; rowspan=2| &amp;lt;div class=&amp;quot;mp_left_border mp_gradient_border&amp;quot;&amp;gt;&lt;br /&gt;
| class=&amp;quot;MainPageBG&amp;quot; style=&amp;quot;width:50%; border:3px solid #6190F4; background:#C5D4F7; vertical-align:top; color:#000;&amp;quot; |&lt;br /&gt;
{| id=&amp;quot;mp-left&amp;quot; style=&amp;quot;width:100%; vertical-align:top; background:#C5D4F7;&amp;quot;&lt;br /&gt;
| style=&amp;quot;padding:2px;&amp;quot; | &amp;lt;h2 id=&amp;quot;mp-tfa-h2&amp;quot; style=&amp;quot;margin:3px; background:#6190F4; font-size:120%; font-weight:bold; border:1px solid #00001F; text-align:left; color:#000; padding:0.2em 0.4em;&amp;quot;&amp;gt;What is Project AU?&amp;lt;/h2&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;color:#000;&amp;quot; | &amp;lt;div id=&amp;quot;mp-tfa&amp;quot; style=&amp;quot;padding:2px 5px&amp;quot;&amp;gt;content goes here&amp;lt;/div&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding:2px;&amp;quot; | &amp;lt;h2 id=&amp;quot;mp-dyk-h2&amp;quot; style=&amp;quot;margin:3px; background:#6190F4; font-size:120%; font-weight:bold; border:1px solid #00001F; text-align:left; color:#000; padding:0.2em 0.4em;&amp;quot;&amp;gt;Recent Changes&amp;lt;/h2&amp;gt;&lt;br /&gt;
{{Special:RecentChanges/20}}&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
| style=&amp;quot;border:1px solid transparent;&amp;quot; |&lt;br /&gt;
| class=&amp;quot;MainPageBG&amp;quot; style=&amp;quot;width:50%; border:3px solid #6190F4; background:#C5D4F7; vertical-align:top;&amp;quot;|&lt;br /&gt;
{| id=&amp;quot;mp-right&amp;quot; style=&amp;quot;width:100%; vertical-align:top; background:#C5D4F7;&amp;quot;&lt;br /&gt;
| style=&amp;quot;padding:2px;&amp;quot; | &amp;lt;h2 id=&amp;quot;mp-itn-h2&amp;quot; style=&amp;quot;margin:3px; background:#6190F4; font-size:120%; font-weight:bold; border:1px solid #00001F; text-align:left; color:#000; padding:0.2em 0.4em;&amp;quot;&amp;gt;History&amp;lt;/h2&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;color:#000; padding:2px 5px;&amp;quot; | &amp;lt;div id=&amp;quot;mp-itn&amp;quot;&amp;gt;content goes here&amp;lt;/div&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding:2px;&amp;quot; | &amp;lt;h2 id=&amp;quot;mp-otd-h2&amp;quot; style=&amp;quot;margin:3px; background:#6190F4; font-size:120%; font-weight:bold; border:1px solid #00001F; text-align:left; color:#000; padding:0.2em 0.4em;&amp;quot;&amp;gt;Nations&amp;lt;/h2&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;color:#000; padding:2px 5px 5px;&amp;quot; | &amp;lt;div id=&amp;quot;mp-otd&amp;quot;&amp;gt;[[Coalition of Allied Star Systems]] • [[Eternal Rulership of the Four Fortresses]] • [[Great Huai]] • [[Holy Worlds under Gafua]] • [[Serene Union of the Tbeew Cluster]] • [[Star Union of Systems]] • [[United Astradom of Thynhe-Gyftpoul]]&amp;lt;/div&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding:2px;&amp;quot; | &amp;lt;h2 id=&amp;quot;mp-otd-h2&amp;quot; style=&amp;quot;margin:3px; background:#6190F4; font-size:120%; font-weight:bold; border:1px solid #00001F; text-align:left; color:#000; padding:0.2em 0.4em;&amp;quot;&amp;gt;Planets&amp;lt;/h2&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;color:#000; padding:2px 5px 5px;&amp;quot; | &amp;lt;div id=&amp;quot;mp-otd&amp;quot;&amp;gt;content goes here&amp;lt;/div&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Marie</name></author>
	</entry>
	<entry>
		<id>http://project-au.w.kmwc.org/index.php?title=Puraetasism&amp;diff=2064</id>
		<title>Puraetasism</title>
		<link rel="alternate" type="text/html" href="http://project-au.w.kmwc.org/index.php?title=Puraetasism&amp;diff=2064"/>
		<updated>2026-01-13T09:53:33Z</updated>

		<summary type="html">&lt;p&gt;Marie: /* Canon of thought */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&#039;&#039;&#039;Puraetasism&#039;&#039;&#039; is a school of thought, sometimes also referred to as a religion, that advocates a return the Pure Age of the Great Men. Puraetasists believe that prior to the Icnosis, humans originated from the civilization of the Great Men, tall beings who had ruled over their home system for generations and lived utopian lives. This was the Pure Age, a time when humanity was at its peak. They believe the current generation of humanity is a lesser imitation of the Great Men, and that they were banished following the Great Insolence, causing the Icnosis. Seeing this as a disgrace, they seek to re-integrate into the society of the Great Men by emulating them as closely as possible, and hold pre-Icnosis records as near-sacred objects.&lt;br /&gt;
The classification of Puraetasism as an ideology or a religion is still a matter of debate. Officially, the [[United Astradom of Thynhe-Gyftpoul]] has no official religion, and many Puraetasists identify as atheists or with another minor religion. A majority of Puraetasists within the Astradom of Thynhe-Gyftpoul will define their beliefs as pure fact, reason, and science. However, in practice, it acts as a state religion and the guiding philosophy of many in Thynhe-Gyftpoul. It can be classified as a form of [[Geolatry]]. &lt;br /&gt;
&lt;br /&gt;
==History==&lt;br /&gt;
Puraetasism arose circa the 3rd Century AAI in the [[Incognita|Incognita system]].&lt;br /&gt;
&lt;br /&gt;
==Canon of thought==&lt;br /&gt;
Due to the relative rarity of pre-[[Icnosis]] record, little is known of the Great Men. From historical records it is known that the Great Men came from the [[Sol system]] on a planet called [[Earth]], and that for many years, the Earth was disunited and warring.&lt;br /&gt;
&lt;br /&gt;
===The World War===&lt;br /&gt;
Prior to the Renaissance and the Pure Age, and before the rise of the Great Men, Earth was subject to the World War. A devastating conflict that spanned the entirety of Earth and all its petty kingdoms. The World War would span for 67 years, from X to X, involving Kingdoms of [[America]], the Soviets, Germania, [[China]], the Indies, Great Britain, Scandinavia, and X. The World Wars are recorded as being a victory for the Kingdom of America, under the leadership of [[Gintama Buddha]]. X&lt;br /&gt;
&lt;br /&gt;
===The Renaissance and the Pure Age===&lt;br /&gt;
The warring and disunited state of Earth changed with the Renaissance, where a great many artistic and scientific advancements were made. This marked the beginning of the Pure Age, where some of the first Great Men were recorded. [[Michelangelo|Míkyl Anhylo]], the Great King of Floures, created many great artworks and statues in his time. In one, he depicts the bringing of mankind together among the stars. In another, he depicts the great conqueror and general [[Neil Armstrong|Nýl Ónstoun]], who subdued and conquered the moon of Luna. It is believed that at some point the King of America [[Jesus|Cézy]], united the various states of the Great Men into the Great Kingdom of Earth, as well as bringing Luna under his dominion. Cézy was the greatest of the Great Men, under his rule, Earth reached a pinacle of technological ascendancy. It is recorded that under his rule, diseases could be entirely eliminated and pushed to extinction, humans could be genetically altered to live incredible lifespans, and that every human treated each other with respect and dignity. Earth would be made into a utopia, and would see expansion throughout the stars.&lt;br /&gt;
&lt;br /&gt;
===The Great Insolence===&lt;br /&gt;
&lt;br /&gt;
[[Category:Ideologies]][[Category:Religions]]&lt;/div&gt;</summary>
		<author><name>Marie</name></author>
	</entry>
	<entry>
		<id>http://project-au.w.kmwc.org/index.php?title=Puraetasism&amp;diff=2063</id>
		<title>Puraetasism</title>
		<link rel="alternate" type="text/html" href="http://project-au.w.kmwc.org/index.php?title=Puraetasism&amp;diff=2063"/>
		<updated>2026-01-13T09:43:47Z</updated>

		<summary type="html">&lt;p&gt;Marie: /* The Renaissance */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&#039;&#039;&#039;Puraetasism&#039;&#039;&#039; is a school of thought, sometimes also referred to as a religion, that advocates a return the Pure Age of the Great Men. Puraetasists believe that prior to the Icnosis, humans originated from the civilization of the Great Men, tall beings who had ruled over their home system for generations and lived utopian lives. This was the Pure Age, a time when humanity was at its peak. They believe the current generation of humanity is a lesser imitation of the Great Men, and that they were banished following the Great Insolence, causing the Icnosis. Seeing this as a disgrace, they seek to re-integrate into the society of the Great Men by emulating them as closely as possible, and hold pre-Icnosis records as near-sacred objects.&lt;br /&gt;
The classification of Puraetasism as an ideology or a religion is still a matter of debate. Officially, the [[United Astradom of Thynhe-Gyftpoul]] has no official religion, and many Puraetasists identify as atheists or with another minor religion. A majority of Puraetasists within the Astradom of Thynhe-Gyftpoul will define their beliefs as pure fact, reason, and science. However, in practice, it acts as a state religion and the guiding philosophy of many in Thynhe-Gyftpoul. It can be classified as a form of [[Geolatry]]. &lt;br /&gt;
&lt;br /&gt;
==History==&lt;br /&gt;
Puraetasism arose circa the 3rd Century AAI in the [[Incognita|Incognita system]].&lt;br /&gt;
&lt;br /&gt;
==Canon of thought==&lt;br /&gt;
Due to the relative rarity of pre-[[Icnosis]] record, little is known of the Great Men. From historical records it is known that the Great Men came from the [[Sol system]] on a planet called [[Earth]], and that for many years, the Earth was disunited and warring.&lt;br /&gt;
&lt;br /&gt;
===The Renaissance===&lt;br /&gt;
The warring and disunited state of Earth changed with the Renaissance, where a great many artistic and scientific advancements were made. This marked the beginning of the Pure Age, where some of the first Great Men were recorded. [[Michelangelo|Míkyl Anhylo]], the Great King of Floures, created many great artworks and statues in his time. In one, he depicts the bringing of mankind together among the stars. In another, he depicts the great conqueror and general [[Neil Armstrong|Nýl Ónstoun]], who subdued and conquered the moon of Luna. It is believed that at some point the King of [[America]] [[Jesus|Cézy]], united the various states of the Great Men into the Great Kingdom of Earth, as well as bringing Luna under his dominion. Cézy was the greatest of the Great Men, under his rule, Earth reached a pinacle of technological ascendancy. It is recorded that under his rule, diseases could be entirely eliminated and pushed to extinction, humans could be genetically altered to live incredible lifespans, and that every human treated each other with respect and dignity. Earth would be made into a utopia, and would see expansion throughout the stars.&lt;br /&gt;
&lt;br /&gt;
===The Pure Age===&lt;br /&gt;
&lt;br /&gt;
===The Great Insolence===&lt;br /&gt;
&lt;br /&gt;
[[Category:Ideologies]][[Category:Religions]]&lt;/div&gt;</summary>
		<author><name>Marie</name></author>
	</entry>
	<entry>
		<id>http://project-au.w.kmwc.org/index.php?title=Puraetasism&amp;diff=2062</id>
		<title>Puraetasism</title>
		<link rel="alternate" type="text/html" href="http://project-au.w.kmwc.org/index.php?title=Puraetasism&amp;diff=2062"/>
		<updated>2026-01-13T09:42:50Z</updated>

		<summary type="html">&lt;p&gt;Marie: /* Canon of thought */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&#039;&#039;&#039;Puraetasism&#039;&#039;&#039; is a school of thought, sometimes also referred to as a religion, that advocates a return the Pure Age of the Great Men. Puraetasists believe that prior to the Icnosis, humans originated from the civilization of the Great Men, tall beings who had ruled over their home system for generations and lived utopian lives. This was the Pure Age, a time when humanity was at its peak. They believe the current generation of humanity is a lesser imitation of the Great Men, and that they were banished following the Great Insolence, causing the Icnosis. Seeing this as a disgrace, they seek to re-integrate into the society of the Great Men by emulating them as closely as possible, and hold pre-Icnosis records as near-sacred objects.&lt;br /&gt;
The classification of Puraetasism as an ideology or a religion is still a matter of debate. Officially, the [[United Astradom of Thynhe-Gyftpoul]] has no official religion, and many Puraetasists identify as atheists or with another minor religion. A majority of Puraetasists within the Astradom of Thynhe-Gyftpoul will define their beliefs as pure fact, reason, and science. However, in practice, it acts as a state religion and the guiding philosophy of many in Thynhe-Gyftpoul. It can be classified as a form of [[Geolatry]]. &lt;br /&gt;
&lt;br /&gt;
==History==&lt;br /&gt;
Puraetasism arose circa the 3rd Century AAI in the [[Incognita|Incognita system]].&lt;br /&gt;
&lt;br /&gt;
==Canon of thought==&lt;br /&gt;
Due to the relative rarity of pre-[[Icnosis]] record, little is known of the Great Men. From historical records it is known that the Great Men came from the [[Sol system]] on a planet called [[Earth]], and that for many years, the Earth was disunited and warring.&lt;br /&gt;
&lt;br /&gt;
===The Renaissance===&lt;br /&gt;
The warring and disunited state of Earth changed with the Renaissance, where a great many artistic and scientific advancements were made. This marked the beginning of the Pure Age, where some of the first Great Men were recorded. [[Michelangelo|Míkyl Anhylo]], the Great King of Floures, created many great artworks and statues in his time. In one, he depicts the bringing of mankind together among the stars. In another, he depicts the great conqueror and general [[Neil Armstrong|Nýl Ónstoun]], who subdued and conquered the moon of Luna. It is believed that at some point the King of [[America]] [[Jesus|Cézy]], united the various states of the Great Men into the Great Kingdom of Earth, as well as bringing Luna under his dominion. Cézy was the greatest of the Great Men, under his rule, Earth reached a pinacle of technological ascendancy. It is recorded that under his rule, diseases could be entirely eliminated and pushed to extinction, humans could be genetically altered to live incredible lifespans, and that every human treated each other with respect and dignity. Earth would be made into a utopia&lt;br /&gt;
&lt;br /&gt;
===The Pure Age===&lt;br /&gt;
&lt;br /&gt;
===The Great Insolence===&lt;br /&gt;
&lt;br /&gt;
[[Category:Ideologies]][[Category:Religions]]&lt;/div&gt;</summary>
		<author><name>Marie</name></author>
	</entry>
	<entry>
		<id>http://project-au.w.kmwc.org/index.php?title=Tetropsid&amp;diff=2059</id>
		<title>Tetropsid</title>
		<link rel="alternate" type="text/html" href="http://project-au.w.kmwc.org/index.php?title=Tetropsid&amp;diff=2059"/>
		<updated>2026-01-13T08:13:55Z</updated>

		<summary type="html">&lt;p&gt;Marie: Created page with &amp;quot;{{Taxobox | name               = Tetropsid | image              = Tetropsid scale.png | image_upright      = | image_alt          =  | image_caption      = Diagram showing the side of a Tetropsid, with a Human for comparison | status             = LC | colour_as          = Animalia | regnum             = ? | phylum             = ? | classis            = ? | superordo          = ? | ordo               = ? | superfamilia       = ? | familia            = ? | genus...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Taxobox&lt;br /&gt;
| name               = Tetropsid&lt;br /&gt;
| image              = Tetropsid scale.png&lt;br /&gt;
| image_upright      =&lt;br /&gt;
| image_alt          = &lt;br /&gt;
| image_caption      = Diagram showing the side of a Tetropsid, with a Human for comparison&lt;br /&gt;
| status             = LC&lt;br /&gt;
| colour_as          = Animalia&lt;br /&gt;
| regnum             = ?&lt;br /&gt;
| phylum             = ?&lt;br /&gt;
| classis            = ?&lt;br /&gt;
| superordo          = ?&lt;br /&gt;
| ordo               = ?&lt;br /&gt;
| superfamilia       = ?&lt;br /&gt;
| familia            = ?&lt;br /&gt;
| genus              = ?&lt;br /&gt;
| species            = &#039;&#039;&#039;?&#039;&#039;&#039;&lt;br /&gt;
| binomial           = &#039;&#039;? ?&#039;&#039;&lt;br /&gt;
| binomial_authority = &lt;br /&gt;
| range_map          = &amp;lt;!--optional map—also range map2, 3 or 4 --&amp;gt;&lt;br /&gt;
| range_map_upright    = &lt;br /&gt;
| range map_alt      = &lt;br /&gt;
| range_map_caption  = &lt;br /&gt;
| &amp;lt;!--or 115 other parameters--&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Tetropsids&#039;&#039;&#039;.&lt;/div&gt;</summary>
		<author><name>Marie</name></author>
	</entry>
	<entry>
		<id>http://project-au.w.kmwc.org/index.php?title=File:Tetropsid_scale.png&amp;diff=2058</id>
		<title>File:Tetropsid scale.png</title>
		<link rel="alternate" type="text/html" href="http://project-au.w.kmwc.org/index.php?title=File:Tetropsid_scale.png&amp;diff=2058"/>
		<updated>2026-01-13T08:12:07Z</updated>

		<summary type="html">&lt;p&gt;Marie: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Marie</name></author>
	</entry>
	<entry>
		<id>http://project-au.w.kmwc.org/index.php?title=FTL_travel&amp;diff=2053</id>
		<title>FTL travel</title>
		<link rel="alternate" type="text/html" href="http://project-au.w.kmwc.org/index.php?title=FTL_travel&amp;diff=2053"/>
		<updated>2026-01-12T16:47:05Z</updated>

		<summary type="html">&lt;p&gt;Marie: Redirected page to Space pulling technology&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;#REDIRECT[[Space pulling technology]]&lt;/div&gt;</summary>
		<author><name>Marie</name></author>
	</entry>
	<entry>
		<id>http://project-au.w.kmwc.org/index.php?title=Saltarplectane&amp;diff=1819</id>
		<title>Saltarplectane</title>
		<link rel="alternate" type="text/html" href="http://project-au.w.kmwc.org/index.php?title=Saltarplectane&amp;diff=1819"/>
		<updated>2025-05-04T13:13:43Z</updated>

		<summary type="html">&lt;p&gt;Marie: /* Anatomy and physiology */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Taxobox&lt;br /&gt;
| name               = Saltarplectane&lt;br /&gt;
| image              = Saltarplectane scale.png&lt;br /&gt;
| image_upright      =&lt;br /&gt;
| image_alt          = &lt;br /&gt;
| image_caption      = Diagram showing the side of a Saltarplectane, with a Human for comparison&lt;br /&gt;
| status             = LC&lt;br /&gt;
| colour_as          = Animalia&lt;br /&gt;
| regnum             = [[Dwicozoan]]&lt;br /&gt;
| phylum             = [[Macroflecta]]&lt;br /&gt;
| classis            = [[Commamorpha]]&lt;br /&gt;
| superordo          = [[Scleacroa]]&lt;br /&gt;
| ordo               = [[Pedaopoda]] &lt;br /&gt;
| superfamilia       = [[Saltarplectoidea]]&lt;br /&gt;
| familia            = [[Saltarplectidae]]&lt;br /&gt;
| genus              = [[Saltarplectanus]]&lt;br /&gt;
| species            = &#039;&#039;&#039;S. psilopateas&#039;&#039;&#039;&lt;br /&gt;
| binomial           = &#039;&#039;Saltarplectanus psilopateas&#039;&#039;&lt;br /&gt;
| binomial_authority = &lt;br /&gt;
| range_map          = &amp;lt;!--optional map—also range map2, 3 or 4 --&amp;gt;&lt;br /&gt;
| range_map_upright    = &lt;br /&gt;
| range map_alt      = &lt;br /&gt;
| range_map_caption  = &lt;br /&gt;
| &amp;lt;!--or 115 other parameters--&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Saltarplectanes&#039;&#039;&#039; are a sophont species residing in the X cluster of the [[Settled Systems]]. Originating from [[Gafua]] in the [[Hurueefia system]], they are the most widespread species of Pedaopods, and the tallest and longest known sophonts on average.&lt;br /&gt;
&lt;br /&gt;
==Etymology and name==&lt;br /&gt;
The name “Saltarplectane” means “jumping weaver,” though this is a name used merely for humans to refer to the species. In [[Fahaa language|Fahaa]], the official language of the [[Holy Worlds under Gafua]], the Saltarplectanes refer to themselves as &#039;&#039;Hàhaabàà&#039;&#039; (/[[Help:SPA|˨ᴀϱᴀϱ:˨ƚϱ:]]/). The full binomial name is &#039;&#039;Saltarplectanus psilopateas&#039;&#039; with &amp;quot;psilopateas&amp;quot; meaning &amp;quot;smooth walker.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
==Evolution==&lt;br /&gt;
&lt;br /&gt;
==History==&lt;br /&gt;
&lt;br /&gt;
==Habitat and population==&lt;br /&gt;
&lt;br /&gt;
==Biology==&lt;br /&gt;
===Anatomy and physiology===&lt;br /&gt;
Saltarplectanes are extraordinarily long and tall Pedaopods with several hundred pairs of hydraulic limbs, called Solenarions, that serve functions both in locomotion and object manipulation. Like most Pedaopods, these hydraulic limbs are able to provide sudden powerful bursts of force, allowing for high and fast jumps. Saltarplectanes differ from most Pedaopods in that they have grown taller in size and possessing a larger more aerodynamic body and shell, reducing the need for jumping like most smaller Pedaopods by simply retracting their Solenarions and gliding. Saltarplectanes possess a hard shell on their back, for protection from aerial predators and from radiation the star of Gafua naturally produces.&lt;br /&gt;
&lt;br /&gt;
===Life cycle===&lt;br /&gt;
===Diet===&lt;br /&gt;
===Biological variation===&lt;br /&gt;
&lt;br /&gt;
==Culture==&lt;br /&gt;
===Language===&lt;br /&gt;
===Art===&lt;br /&gt;
===Tools and technologies===&lt;br /&gt;
===Religion===&lt;br /&gt;
===Science and philosophy===&lt;br /&gt;
&lt;br /&gt;
==Society==&lt;/div&gt;</summary>
		<author><name>Marie</name></author>
	</entry>
	<entry>
		<id>http://project-au.w.kmwc.org/index.php?title=Saltarplectane&amp;diff=1818</id>
		<title>Saltarplectane</title>
		<link rel="alternate" type="text/html" href="http://project-au.w.kmwc.org/index.php?title=Saltarplectane&amp;diff=1818"/>
		<updated>2025-05-04T10:35:13Z</updated>

		<summary type="html">&lt;p&gt;Marie: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Taxobox&lt;br /&gt;
| name               = Saltarplectane&lt;br /&gt;
| image              = Saltarplectane scale.png&lt;br /&gt;
| image_upright      =&lt;br /&gt;
| image_alt          = &lt;br /&gt;
| image_caption      = Diagram showing the side of a Saltarplectane, with a Human for comparison&lt;br /&gt;
| status             = LC&lt;br /&gt;
| colour_as          = Animalia&lt;br /&gt;
| regnum             = [[Dwicozoan]]&lt;br /&gt;
| phylum             = [[Macroflecta]]&lt;br /&gt;
| classis            = [[Commamorpha]]&lt;br /&gt;
| superordo          = [[Scleacroa]]&lt;br /&gt;
| ordo               = [[Pedaopoda]] &lt;br /&gt;
| superfamilia       = [[Saltarplectoidea]]&lt;br /&gt;
| familia            = [[Saltarplectidae]]&lt;br /&gt;
| genus              = [[Saltarplectanus]]&lt;br /&gt;
| species            = &#039;&#039;&#039;S. psilopateas&#039;&#039;&#039;&lt;br /&gt;
| binomial           = &#039;&#039;Saltarplectanus psilopateas&#039;&#039;&lt;br /&gt;
| binomial_authority = &lt;br /&gt;
| range_map          = &amp;lt;!--optional map—also range map2, 3 or 4 --&amp;gt;&lt;br /&gt;
| range_map_upright    = &lt;br /&gt;
| range map_alt      = &lt;br /&gt;
| range_map_caption  = &lt;br /&gt;
| &amp;lt;!--or 115 other parameters--&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Saltarplectanes&#039;&#039;&#039; are a sophont species residing in the X cluster of the [[Settled Systems]]. Originating from [[Gafua]] in the [[Hurueefia system]], they are the most widespread species of Pedaopods, and the tallest and longest known sophonts on average.&lt;br /&gt;
&lt;br /&gt;
==Etymology and name==&lt;br /&gt;
The name “Saltarplectane” means “jumping weaver,” though this is a name used merely for humans to refer to the species. In [[Fahaa language|Fahaa]], the official language of the [[Holy Worlds under Gafua]], the Saltarplectanes refer to themselves as &#039;&#039;Hàhaabàà&#039;&#039; (/[[Help:SPA|˨ᴀϱᴀϱ:˨ƚϱ:]]/). The full binomial name is &#039;&#039;Saltarplectanus psilopateas&#039;&#039; with &amp;quot;psilopateas&amp;quot; meaning &amp;quot;smooth walker.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
==Evolution==&lt;br /&gt;
&lt;br /&gt;
==History==&lt;br /&gt;
&lt;br /&gt;
==Habitat and population==&lt;br /&gt;
&lt;br /&gt;
==Biology==&lt;br /&gt;
===Anatomy and physiology===&lt;br /&gt;
Saltarplectanes are extraordinarily long and tall Pedaopods with several hundred pairs of hydraulic limbs, called Solenarions, that serve functions both in locomotion and object manipulation. Like most Pedaopods, these hydraulic limbs are able to provide sudden powerful bursts of force, allowing for high and fast jumps. Saltarplectanes differ from most Pedaopods in that they have grown taller in size and possessing a larger more aerodynamic body and shell, reducing the need for jumping like most smaller Pedaopods by simply retracting their Solenarions and gliding. &lt;br /&gt;
&lt;br /&gt;
===Life cycle===&lt;br /&gt;
===Diet===&lt;br /&gt;
===Biological variation===&lt;br /&gt;
&lt;br /&gt;
==Culture==&lt;br /&gt;
===Language===&lt;br /&gt;
===Art===&lt;br /&gt;
===Tools and technologies===&lt;br /&gt;
===Religion===&lt;br /&gt;
===Science and philosophy===&lt;br /&gt;
&lt;br /&gt;
==Society==&lt;/div&gt;</summary>
		<author><name>Marie</name></author>
	</entry>
	<entry>
		<id>http://project-au.w.kmwc.org/index.php?title=Saltarplectane&amp;diff=1817</id>
		<title>Saltarplectane</title>
		<link rel="alternate" type="text/html" href="http://project-au.w.kmwc.org/index.php?title=Saltarplectane&amp;diff=1817"/>
		<updated>2025-05-04T10:31:29Z</updated>

		<summary type="html">&lt;p&gt;Marie: /* Biology */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Taxobox&lt;br /&gt;
| name               = Saltarplectane&lt;br /&gt;
| image              = Saltarplectane scale.png&lt;br /&gt;
| image_upright      =&lt;br /&gt;
| image_alt          = &lt;br /&gt;
| image_caption      = Diagram showing the side of a Saltarplectane, with a Human for comparison&lt;br /&gt;
| status             = LC&lt;br /&gt;
| colour_as          = Animalia&lt;br /&gt;
| regnum             = [[Dwicozoan]]&lt;br /&gt;
| phylum             = [[Macroflecta]]&lt;br /&gt;
| classis            = [[Commamorpha]]&lt;br /&gt;
| superordo          = [[Scleacroa]]&lt;br /&gt;
| ordo               = [[Pedaopoda]] &lt;br /&gt;
| superfamilia       = [[Saltarplectoidea]]&lt;br /&gt;
| familia            = [[Saltarplectidae]]&lt;br /&gt;
| genus              = [[Saltarplectanus]]&lt;br /&gt;
| species            = &#039;&#039;&#039;S. psilopateas&#039;&#039;&#039;&lt;br /&gt;
| binomial           = &#039;&#039;Saltarplectanus psilopateas&#039;&#039;&lt;br /&gt;
| binomial_authority = &lt;br /&gt;
| range_map          = &amp;lt;!--optional map—also range map2, 3 or 4 --&amp;gt;&lt;br /&gt;
| range_map_upright    = &lt;br /&gt;
| range map_alt      = &lt;br /&gt;
| range_map_caption  = &lt;br /&gt;
| &amp;lt;!--or 115 other parameters--&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Saltarplectanes&#039;&#039;&#039; are a sophont species residing in the X cluster of the [[Settled Systems]]. Originating from [[Gafua]] in the [[Hurueefia system]], they are the most widespread species of Pedaopods, and the tallest and longest known sophonts on average.&lt;br /&gt;
&lt;br /&gt;
==Etymology and name==&lt;br /&gt;
The name “Saltarplectane” means “jumping weaver,” though this is a name used merely for humans to refer to the species. In [[Fahaa language|Fahaa]], the official language of the [[Holy Worlds under Gafua]], the Saltarplectanes refer to themselves as &#039;&#039;Hàhaabàà&#039;&#039; (/[[Help:SPA|˨ᴀϱᴀϱ:˨ƚϱ:]]/).&lt;br /&gt;
&lt;br /&gt;
==Evolution==&lt;br /&gt;
&lt;br /&gt;
==History==&lt;br /&gt;
&lt;br /&gt;
==Habitat and population==&lt;br /&gt;
&lt;br /&gt;
==Biology==&lt;br /&gt;
===Anatomy and physiology===&lt;br /&gt;
Saltarplectanes are extraordinarily long and tall Pedaopods with several hundred pairs of hydraulic limbs, called Solenarions, that serve functions both in locomotion and object manipulation. Like most Pedaopods, these hydraulic limbs are able to provide sudden powerful bursts of force, allowing for high and fast jumps. Saltarplectanes differ from most Pedaopods in that they have grown taller in size and possessing a larger more aerodynamic body and shell, reducing the need for jumping like most smaller Pedaopods by simply retracting their Solenarions and gliding. &lt;br /&gt;
&lt;br /&gt;
===Life cycle===&lt;br /&gt;
===Diet===&lt;br /&gt;
===Biological variation===&lt;br /&gt;
&lt;br /&gt;
==Culture==&lt;br /&gt;
===Language===&lt;br /&gt;
===Art===&lt;br /&gt;
===Tools and technologies===&lt;br /&gt;
===Religion===&lt;br /&gt;
===Science and philosophy===&lt;br /&gt;
&lt;br /&gt;
==Society==&lt;/div&gt;</summary>
		<author><name>Marie</name></author>
	</entry>
	<entry>
		<id>http://project-au.w.kmwc.org/index.php?title=Gafua&amp;diff=1816</id>
		<title>Gafua</title>
		<link rel="alternate" type="text/html" href="http://project-au.w.kmwc.org/index.php?title=Gafua&amp;diff=1816"/>
		<updated>2025-05-04T07:05:29Z</updated>

		<summary type="html">&lt;p&gt;Marie: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Infobox planet&lt;br /&gt;
|name         = Gạ̀fuạ&lt;br /&gt;
|image        = Gafua.png&lt;br /&gt;
|alt          =&lt;br /&gt;
|caption      = Gạ̀fuạ from orbit&lt;br /&gt;
|designation  = Hurueefia III&lt;br /&gt;
|satellites   = ?&lt;br /&gt;
|semimajor    = 1.682831&lt;br /&gt;
|diameter     = &lt;br /&gt;
|year_length  = &lt;br /&gt;
|day_length   = &lt;br /&gt;
|gravity      = &lt;br /&gt;
|axial_tilt   = &lt;br /&gt;
|temperature  = &lt;br /&gt;
|atmosphere   = &lt;br /&gt;
 {{unbulleted list |class=nowrap&lt;br /&gt;
  | 84.95% nitrogen (N&amp;lt;small&amp;gt;2&amp;lt;/small&amp;gt;) &amp;lt;small&amp;gt;(dry air)&amp;lt;/small&amp;gt;&lt;br /&gt;
  | 11.02% oxygen (O&amp;lt;small&amp;gt;2&amp;lt;/small&amp;gt;)&lt;br /&gt;
  | X% who knows&lt;br /&gt;
 }}&lt;br /&gt;
|adjective    = &lt;br /&gt;
|population   = ? Billion&lt;br /&gt;
|jurisdiction = [[Holy Worlds under Gafua]]&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
Gafua is the homeworld of the [[Saltarplectane|Saltarplectanes]] and the capital world of the [[Holy Worlds under Gafua]].&lt;br /&gt;
&lt;br /&gt;
[[Category:Planets]]&lt;/div&gt;</summary>
		<author><name>Marie</name></author>
	</entry>
	<entry>
		<id>http://project-au.w.kmwc.org/index.php?title=File:Gafua.png&amp;diff=1815</id>
		<title>File:Gafua.png</title>
		<link rel="alternate" type="text/html" href="http://project-au.w.kmwc.org/index.php?title=File:Gafua.png&amp;diff=1815"/>
		<updated>2025-05-04T07:04:50Z</updated>

		<summary type="html">&lt;p&gt;Marie: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Marie</name></author>
	</entry>
	<entry>
		<id>http://project-au.w.kmwc.org/index.php?title=Saltarplectane&amp;diff=1804</id>
		<title>Saltarplectane</title>
		<link rel="alternate" type="text/html" href="http://project-au.w.kmwc.org/index.php?title=Saltarplectane&amp;diff=1804"/>
		<updated>2025-05-02T07:40:38Z</updated>

		<summary type="html">&lt;p&gt;Marie: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Taxobox&lt;br /&gt;
| name               = Saltarplectane&lt;br /&gt;
| image              = Saltarplectane scale.png&lt;br /&gt;
| image_upright      =&lt;br /&gt;
| image_alt          = &lt;br /&gt;
| image_caption      = Diagram showing the side of a Saltarplectane, with a Human for comparison&lt;br /&gt;
| status             = LC&lt;br /&gt;
| colour_as          = Animalia&lt;br /&gt;
| regnum             = [[Dwicozoan]]&lt;br /&gt;
| phylum             = [[Macroflecta]]&lt;br /&gt;
| classis            = [[Commamorpha]]&lt;br /&gt;
| superordo          = [[Scleacroa]]&lt;br /&gt;
| ordo               = [[Pedaopoda]] &lt;br /&gt;
| superfamilia       = [[Saltarplectoidea]]&lt;br /&gt;
| familia            = [[Saltarplectidae]]&lt;br /&gt;
| genus              = [[Saltarplectanus]]&lt;br /&gt;
| species            = &#039;&#039;&#039;S. psilopateas&#039;&#039;&#039;&lt;br /&gt;
| binomial           = &#039;&#039;Saltarplectanus psilopateas&#039;&#039;&lt;br /&gt;
| binomial_authority = &lt;br /&gt;
| range_map          = &amp;lt;!--optional map—also range map2, 3 or 4 --&amp;gt;&lt;br /&gt;
| range_map_upright    = &lt;br /&gt;
| range map_alt      = &lt;br /&gt;
| range_map_caption  = &lt;br /&gt;
| &amp;lt;!--or 115 other parameters--&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Saltarplectanes&#039;&#039;&#039; are a sophont species residing in the X cluster of the [[Settled Systems]]. Originating from [[Gafua]] in the [[Hurueefia system]], they are the most widespread species of Pedaopods, and the tallest and longest known sophonts on average.&lt;br /&gt;
&lt;br /&gt;
==Etymology and name==&lt;br /&gt;
The name “Saltarplectane” means “jumping weaver,” though this is a name used merely for humans to refer to the species. In [[Fahaa language|Fahaa]], the official language of the [[Holy Worlds under Gafua]], the Saltarplectanes refer to themselves as &#039;&#039;Hàhaabàà&#039;&#039; (/[[Help:SPA|˨ᴀϱᴀϱ:˨ƚϱ:]]/).&lt;br /&gt;
&lt;br /&gt;
==Evolution==&lt;br /&gt;
&lt;br /&gt;
==History==&lt;br /&gt;
&lt;br /&gt;
==Habitat and population==&lt;br /&gt;
&lt;br /&gt;
==Biology==&lt;br /&gt;
===Anatomy and physiology===&lt;br /&gt;
Saltarplectanes are extraordinarily long and tall Pedaopods with several hundred pairs of hydraulic limbs, called Solenarions, that serve functions both in locomotion and object manipulation. Like most Pedaopods, these hydraulic limbs are able to provide sudden powerful bursts of force, allowing for high and fast jumps. Saltarplectanes differ from most Pedaopods in that they have grown taller in size and possessing a larger more aerodynamic body and shell, reducing the need for jumping like most smaller Pedaopods by simply retracting their Solenarions and gliding.&lt;br /&gt;
&lt;br /&gt;
===Life cycle===&lt;br /&gt;
===Diet===&lt;br /&gt;
===Biological variation===&lt;br /&gt;
&lt;br /&gt;
==Culture==&lt;br /&gt;
===Language===&lt;br /&gt;
===Art===&lt;br /&gt;
===Tools and technologies===&lt;br /&gt;
===Religion===&lt;br /&gt;
===Science and philosophy===&lt;br /&gt;
&lt;br /&gt;
==Society==&lt;/div&gt;</summary>
		<author><name>Marie</name></author>
	</entry>
	<entry>
		<id>http://project-au.w.kmwc.org/index.php?title=Saltarplectane&amp;diff=1803</id>
		<title>Saltarplectane</title>
		<link rel="alternate" type="text/html" href="http://project-au.w.kmwc.org/index.php?title=Saltarplectane&amp;diff=1803"/>
		<updated>2025-05-02T07:37:40Z</updated>

		<summary type="html">&lt;p&gt;Marie: /* Anatomy and physiology */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Taxobox&lt;br /&gt;
| name               = Saltarplectane&lt;br /&gt;
| image              = Saltarplectane scale.png&lt;br /&gt;
| image_upright      =&lt;br /&gt;
| image_alt          = &lt;br /&gt;
| image_caption      = Diagram showing the side of a Saltarplectane, with a Human for comparison&lt;br /&gt;
| status             = LC&lt;br /&gt;
| colour_as          = Animalia&lt;br /&gt;
| regnum             = [[Dwicozoan]]&lt;br /&gt;
| phylum             = [[Macroflecta]]&lt;br /&gt;
| classis            = [[Commamorpha]]&lt;br /&gt;
| superordo          = [[Scleacroa]]&lt;br /&gt;
| ordo               = [[Pedaopoda]] &lt;br /&gt;
| superfamilia       = [[Saltarplectoidea]]&lt;br /&gt;
| familia            = [[Saltarplectidae]]&lt;br /&gt;
| genus              = [[Saltarplectanus]]&lt;br /&gt;
| species            = &#039;&#039;&#039;S. psilopateas&#039;&#039;&#039;&lt;br /&gt;
| binomial           = &#039;&#039;Saltarplectanus psilopateas&#039;&#039;&lt;br /&gt;
| binomial_authority = &lt;br /&gt;
| range_map          = &amp;lt;!--optional map—also range map2, 3 or 4 --&amp;gt;&lt;br /&gt;
| range_map_upright    = &lt;br /&gt;
| range map_alt      = &lt;br /&gt;
| range_map_caption  = &lt;br /&gt;
| &amp;lt;!--or 115 other parameters--&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Saltarplectanes&#039;&#039;&#039; are a sophont species residing in the X cluster of the [[Settled Systems]]. Originating from [[Gafua]] in the [[Hurueefia system]], they are the most widespread species of Pedaopods, and the tallest and longest sophonts known on average.&lt;br /&gt;
&lt;br /&gt;
==Etymology and name==&lt;br /&gt;
The name “Saltarplectane” means “jumping weaver,” though this is a name used merely for humans to refer to the species. In [[Fahaa language|Fahaa]], the official language of the [[Holy Worlds under Gafua]], the Saltarplectanes refer to themselves as &#039;&#039;Hàhaabàà&#039;&#039; (/[[Help:SPA|˨ᴀϱᴀϱ:˨ƚϱ:]]/).&lt;br /&gt;
&lt;br /&gt;
==Evolution==&lt;br /&gt;
&lt;br /&gt;
==History==&lt;br /&gt;
&lt;br /&gt;
==Habitat and population==&lt;br /&gt;
&lt;br /&gt;
==Biology==&lt;br /&gt;
===Anatomy and physiology===&lt;br /&gt;
Saltarplectanes are extraordinarily long and tall Pedaopods with several hundred pairs of hydraulic limbs, called Solenarions, that serve functions both in locomotion and object manipulation. Like most Pedaopods, these hydraulic limbs are able to provide sudden powerful bursts of force, allowing for high and fast jumps. Saltarplectanes differ from most Pedaopods in that they have grown taller in size and possessing a larger more aerodynamic body and shell, reducing the need for jumping like most smaller Pedaopods by simply retracting their Solenarions and gliding.&lt;br /&gt;
&lt;br /&gt;
===Life cycle===&lt;br /&gt;
===Diet===&lt;br /&gt;
===Biological variation===&lt;br /&gt;
&lt;br /&gt;
==Culture==&lt;br /&gt;
===Language===&lt;br /&gt;
===Art===&lt;br /&gt;
===Tools and technologies===&lt;br /&gt;
===Religion===&lt;br /&gt;
===Science and philosophy===&lt;br /&gt;
&lt;br /&gt;
==Society==&lt;/div&gt;</summary>
		<author><name>Marie</name></author>
	</entry>
	<entry>
		<id>http://project-au.w.kmwc.org/index.php?title=Saltarplectane&amp;diff=1802</id>
		<title>Saltarplectane</title>
		<link rel="alternate" type="text/html" href="http://project-au.w.kmwc.org/index.php?title=Saltarplectane&amp;diff=1802"/>
		<updated>2025-05-02T07:26:25Z</updated>

		<summary type="html">&lt;p&gt;Marie: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Taxobox&lt;br /&gt;
| name               = Saltarplectane&lt;br /&gt;
| image              = Saltarplectane scale.png&lt;br /&gt;
| image_upright      =&lt;br /&gt;
| image_alt          = &lt;br /&gt;
| image_caption      = Diagram showing the side of a Saltarplectane, with a Human for comparison&lt;br /&gt;
| status             = LC&lt;br /&gt;
| colour_as          = Animalia&lt;br /&gt;
| regnum             = [[Dwicozoan]]&lt;br /&gt;
| phylum             = [[Macroflecta]]&lt;br /&gt;
| classis            = [[Commamorpha]]&lt;br /&gt;
| superordo          = [[Scleacroa]]&lt;br /&gt;
| ordo               = [[Pedaopoda]] &lt;br /&gt;
| superfamilia       = [[Saltarplectoidea]]&lt;br /&gt;
| familia            = [[Saltarplectidae]]&lt;br /&gt;
| genus              = [[Saltarplectanus]]&lt;br /&gt;
| species            = &#039;&#039;&#039;S. psilopateas&#039;&#039;&#039;&lt;br /&gt;
| binomial           = &#039;&#039;Saltarplectanus psilopateas&#039;&#039;&lt;br /&gt;
| binomial_authority = &lt;br /&gt;
| range_map          = &amp;lt;!--optional map—also range map2, 3 or 4 --&amp;gt;&lt;br /&gt;
| range_map_upright    = &lt;br /&gt;
| range map_alt      = &lt;br /&gt;
| range_map_caption  = &lt;br /&gt;
| &amp;lt;!--or 115 other parameters--&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Saltarplectanes&#039;&#039;&#039; are a sophont species residing in the X cluster of the [[Settled Systems]]. Originating from [[Gafua]] in the [[Hurueefia system]], they are the most widespread species of Pedaopods, and the tallest and longest sophonts known on average.&lt;br /&gt;
&lt;br /&gt;
==Etymology and name==&lt;br /&gt;
The name “Saltarplectane” means “jumping weaver,” though this is a name used merely for humans to refer to the species. In [[Fahaa language|Fahaa]], the official language of the [[Holy Worlds under Gafua]], the Saltarplectanes refer to themselves as &#039;&#039;Hàhaabàà&#039;&#039; (/[[Help:SPA|˨ᴀϱᴀϱ:˨ƚϱ:]]/).&lt;br /&gt;
&lt;br /&gt;
==Evolution==&lt;br /&gt;
&lt;br /&gt;
==History==&lt;br /&gt;
&lt;br /&gt;
==Habitat and population==&lt;br /&gt;
&lt;br /&gt;
==Biology==&lt;br /&gt;
===Anatomy and physiology===&lt;br /&gt;
===Life cycle===&lt;br /&gt;
===Diet===&lt;br /&gt;
===Biological variation===&lt;br /&gt;
&lt;br /&gt;
==Culture==&lt;br /&gt;
===Language===&lt;br /&gt;
===Art===&lt;br /&gt;
===Tools and technologies===&lt;br /&gt;
===Religion===&lt;br /&gt;
===Science and philosophy===&lt;br /&gt;
&lt;br /&gt;
==Society==&lt;/div&gt;</summary>
		<author><name>Marie</name></author>
	</entry>
	<entry>
		<id>http://project-au.w.kmwc.org/index.php?title=Saltarplectane&amp;diff=1801</id>
		<title>Saltarplectane</title>
		<link rel="alternate" type="text/html" href="http://project-au.w.kmwc.org/index.php?title=Saltarplectane&amp;diff=1801"/>
		<updated>2025-05-02T07:13:21Z</updated>

		<summary type="html">&lt;p&gt;Marie: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Taxobox&lt;br /&gt;
| name               = Saltarplectane&lt;br /&gt;
| image              = Saltarplectane scale.png&lt;br /&gt;
| image_upright      =&lt;br /&gt;
| image_alt          = &lt;br /&gt;
| image_caption      = Diagram showing the side of a Saltarplectane, with a Human for comparison&lt;br /&gt;
| status             = LC&lt;br /&gt;
| colour_as          = Animalia&lt;br /&gt;
| regnum             = [[Dwicozoan]]&lt;br /&gt;
| phylum             = [[Macroflecta]]&lt;br /&gt;
| classis            = [[Commamorpha]]&lt;br /&gt;
| superordo          = [[Scleacroa]]&lt;br /&gt;
| ordo               = [[Pedaopoda]] &lt;br /&gt;
| superfamilia       = [[Saltarplectoidea]]&lt;br /&gt;
| familia            = [[Saltarplectidae]]&lt;br /&gt;
| genus              = [[Saltarplectanus]]&lt;br /&gt;
| species            = &#039;&#039;&#039;S. psilopateas&#039;&#039;&#039;&lt;br /&gt;
| binomial           = &#039;&#039;Saltarplectanus psilopateas&#039;&#039;&lt;br /&gt;
| binomial_authority = &lt;br /&gt;
| range_map          = &amp;lt;!--optional map—also range map2, 3 or 4 --&amp;gt;&lt;br /&gt;
| range_map_upright    = &lt;br /&gt;
| range map_alt      = &lt;br /&gt;
| range_map_caption  = &lt;br /&gt;
| &amp;lt;!--or 115 other parameters--&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Saltarplectanes&#039;&#039;&#039; are a sophont species residing in the X cluster of the [[Settled Systems]]. Originating from [[Gafua]] in the [[Hurueefia system]], they are the most widespread species of Pedaopods, and the tallest and longest sophonts known on average.&lt;/div&gt;</summary>
		<author><name>Marie</name></author>
	</entry>
	<entry>
		<id>http://project-au.w.kmwc.org/index.php?title=File:Saltarplectane_scale.png&amp;diff=1800</id>
		<title>File:Saltarplectane scale.png</title>
		<link rel="alternate" type="text/html" href="http://project-au.w.kmwc.org/index.php?title=File:Saltarplectane_scale.png&amp;diff=1800"/>
		<updated>2025-05-02T07:12:04Z</updated>

		<summary type="html">&lt;p&gt;Marie: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Marie</name></author>
	</entry>
</feed>