<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.tiffa.net/w/index.php?action=history&amp;feed=atom&amp;title=Module%3ASettlement_short_description</id>
	<title>Module:Settlement short description - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.tiffa.net/w/index.php?action=history&amp;feed=atom&amp;title=Module%3ASettlement_short_description"/>
	<link rel="alternate" type="text/html" href="https://wiki.tiffa.net/w/index.php?title=Module:Settlement_short_description&amp;action=history"/>
	<updated>2026-04-03T23:37:32Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.0</generator>
	<entry>
		<id>https://wiki.tiffa.net/w/index.php?title=Module:Settlement_short_description&amp;diff=148665&amp;oldid=prev</id>
		<title>Fire: Created page with &quot;--generates auto short description for use in infobox settlement local p = {} p.categories = &quot;&quot; local plain = require(&#039;Module:Plain text&#039;)._main local getArgs = require(&#039;Module:Arguments&#039;).getArgs local tableTools = require (&#039;Module:TableTools&#039;)  function p.reverseTable (init) 	init[1], init[3] = init[3], init[1] 	return init end  function p.assign (args, argname, num) 	local val 	local var = {} 	for i = 0,num do 		--handle initial &quot;subdivision_foo&quot; without number 		if i...&quot;</title>
		<link rel="alternate" type="text/html" href="https://wiki.tiffa.net/w/index.php?title=Module:Settlement_short_description&amp;diff=148665&amp;oldid=prev"/>
		<updated>2025-06-03T00:23:16Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;--generates auto short description for use in infobox settlement local p = {} p.categories = &amp;quot;&amp;quot; local plain = require(&amp;#039;Module:Plain text&amp;#039;)._main local getArgs = require(&amp;#039;Module:Arguments&amp;#039;).getArgs local tableTools = require (&amp;#039;Module:TableTools&amp;#039;)  function p.reverseTable (init) 	init[1], init[3] = init[3], init[1] 	return init end  function p.assign (args, argname, num) 	local val 	local var = {} 	for i = 0,num do 		--handle initial &amp;quot;subdivision_foo&amp;quot; without number 		if i...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;--generates auto short description for use in infobox settlement&lt;br /&gt;
local p = {}&lt;br /&gt;
p.categories = &amp;quot;&amp;quot;&lt;br /&gt;
local plain = require(&amp;#039;Module:Plain text&amp;#039;)._main&lt;br /&gt;
local getArgs = require(&amp;#039;Module:Arguments&amp;#039;).getArgs&lt;br /&gt;
local tableTools = require (&amp;#039;Module:TableTools&amp;#039;)&lt;br /&gt;
&lt;br /&gt;
function p.reverseTable (init)&lt;br /&gt;
	init[1], init[3] = init[3], init[1]&lt;br /&gt;
	return init&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p.assign (args, argname, num)&lt;br /&gt;
	local val&lt;br /&gt;
	local var = {}&lt;br /&gt;
	for i = 0,num do&lt;br /&gt;
		--handle initial &amp;quot;subdivision_foo&amp;quot; without number&lt;br /&gt;
		if i == 0 then&lt;br /&gt;
			val = &amp;quot;&amp;quot;&lt;br /&gt;
		else&lt;br /&gt;
			val = tostring(i)&lt;br /&gt;
		end&lt;br /&gt;
		var[i+1] = p.validate(plain(args[argname..val]))&lt;br /&gt;
	end&lt;br /&gt;
	return var&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--Display short description using {{short description}}&lt;br /&gt;
function p.shortdesc(text, frame)&lt;br /&gt;
	return frame:expandTemplate{title = &amp;#039;Short description&amp;#039;, args = {text, &amp;#039;noreplace&amp;#039;}}&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p.category (cattype)&lt;br /&gt;
	local category = string.format(&amp;#039;[[Category:Pages using infobox settlement with bad %s]]&amp;#039;, cattype)&lt;br /&gt;
	if category then p.categories = p.categories..category end --categorize&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--sanity and other checks&lt;br /&gt;
function p.validate (parameter, cat)&lt;br /&gt;
	if not parameter then return nil end&lt;br /&gt;
	parameter = parameter:gsub(&amp;#039;%b()&amp;#039;, &amp;#039;&amp;#039;) --remove things in brackets as extraneous information&lt;br /&gt;
			   :gsub(&amp;#039;%s+&amp;#039;, &amp;#039; &amp;#039;) --fix possible extra spaces from previous cleanup&lt;br /&gt;
			   :gsub(&amp;#039;^%s+&amp;#039;, &amp;#039;&amp;#039;) --trim spaces from beginning&lt;br /&gt;
			   :gsub(&amp;#039;%s+$&amp;#039;, &amp;#039;&amp;#039;) --trim spaces from end&lt;br /&gt;
	if parameter:match(&amp;quot;[,;]&amp;quot;) or not parameter:match(&amp;quot;%a&amp;quot;) then --must have some letters, ignore if multiple types/subdivisions&lt;br /&gt;
		if cat then p.category (cat) end&lt;br /&gt;
		return nil&lt;br /&gt;
	end&lt;br /&gt;
	if (parameter == &amp;quot;&amp;quot;) then return nil end&lt;br /&gt;
	return parameter&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--removes redundancy like &amp;quot;England, United Kingdom&amp;quot; and fixes issues like &amp;quot;Foo in United States&amp;quot; (to &amp;quot;Foo in the United States&amp;quot;)&lt;br /&gt;
--also used in Module:Type in location&lt;br /&gt;
function p.cleanupLoc (location)&lt;br /&gt;
	if location == &amp;quot;&amp;quot; then return nil end&lt;br /&gt;
	local replacements = {&lt;br /&gt;
		[&amp;quot;England, United Kingdom&amp;quot;] =  &amp;quot;England&amp;quot;,&lt;br /&gt;
		[&amp;quot;Scotland, United Kingdom&amp;quot;] =  &amp;quot;Scotland&amp;quot;,&lt;br /&gt;
		[&amp;quot;Wales, United Kingdom&amp;quot;] =  &amp;quot;Wales&amp;quot;,&lt;br /&gt;
		[&amp;quot;New York City, New York, United States&amp;quot;] =  &amp;quot;New York City&amp;quot;,&lt;br /&gt;
		[&amp;quot;^United States$&amp;quot;] = &amp;quot;the United States&amp;quot;,&lt;br /&gt;
		[&amp;quot;London, United Kingdom&amp;quot;] = &amp;quot;London, England&amp;quot;&lt;br /&gt;
	}&lt;br /&gt;
	for i, v in pairs(replacements) do &lt;br /&gt;
		location = location:gsub(i, v) --series of replacements&lt;br /&gt;
	end&lt;br /&gt;
	return location&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p.main(frame)&lt;br /&gt;
	local categories = &amp;quot;&amp;quot;&lt;br /&gt;
	local subdivision_types = {}&lt;br /&gt;
	local subdivision_names = {}&lt;br /&gt;
	local args = getArgs (frame, {parentOnly = true})&lt;br /&gt;
	local settlement_type = p.validate(plain(args.settlement_type or args.type), &amp;quot;settlement type&amp;quot;) or &amp;quot;Place&amp;quot;&lt;br /&gt;
	local short_description = plain(args.short_description)&lt;br /&gt;
	subdivision_types = p.assign(args, &amp;quot;subdivision_type&amp;quot;, 2)&lt;br /&gt;
	subdivision_names = p.assign(args, &amp;quot;subdivision_name&amp;quot;, 2)&lt;br /&gt;
	&lt;br /&gt;
	if short_description then&lt;br /&gt;
		if (short_description == &amp;#039;no&amp;#039;) then&lt;br /&gt;
			return&lt;br /&gt;
		else&lt;br /&gt;
			local language = mw.language.getContentLanguage()&lt;br /&gt;
			return p.shortdesc(language:ucfirst(short_description), frame)&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	if not(subdivision_names[3] and&lt;br /&gt;
		(string.find(settlement_type, &amp;#039;[nN]eighbo[u]?rhood&amp;#039;) or string.find(settlement_type, &amp;#039;[sS]uburb&amp;#039;))) then&lt;br /&gt;
		subdivision_names[3] = nil --display the third subdivision_type only if suburb or neighborhood&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	--if say &amp;quot;Voivodeship&amp;quot; is found within the subdivision_type, then specially handle&lt;br /&gt;
	--by adding Voivodeship to the end if not already present&lt;br /&gt;
	for x, y in ipairs (subdivision_types) do&lt;br /&gt;
		local special_types = {&lt;br /&gt;
			&amp;quot;Voivodeship&amp;quot;&lt;br /&gt;
		}&lt;br /&gt;
		for i, j in ipairs(special_types) do&lt;br /&gt;
			if subdivision_names[x] and string.find(y, j, 1, true)&lt;br /&gt;
				and not string.find(subdivision_names[x], j, 1, true) then&lt;br /&gt;
				subdivision_names[x] = subdivision_names[x]..&amp;quot; &amp;quot;..j&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	for x, y in ipairs (subdivision_names) do&lt;br /&gt;
		if y then&lt;br /&gt;
			if string.find(settlement_type, y, 1, true) then --if the subdivision is found within the settlement type&lt;br /&gt;
				subdivision_names[x] = nil --don&amp;#039;t display redundancy&lt;br /&gt;
				p.category (&amp;quot;settlement type&amp;quot;)&lt;br /&gt;
			end&lt;br /&gt;
			if y == mw.title.getCurrentTitle().text then --if the title is the same as one of the subdivision_names&lt;br /&gt;
				subdivision_names[x] = nil --don&amp;#039;t display redundancy&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	local location = table.concat(tableTools.compressSparseArray(p.reverseTable(subdivision_names)), &amp;#039;, &amp;#039;)&lt;br /&gt;
	&lt;br /&gt;
	location = p.cleanupLoc (location)&lt;br /&gt;
	&lt;br /&gt;
	if location then location =  &amp;quot; in &amp;quot; .. location else location = &amp;quot;&amp;quot; end&lt;br /&gt;
	&lt;br /&gt;
	local language = mw.language.getContentLanguage()&lt;br /&gt;
	return p.shortdesc(language:ucfirst(settlement_type..location), frame)..p.categories&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
return p&lt;/div&gt;</summary>
		<author><name>Fire</name></author>
	</entry>
</feed>