Module:Settlement short description
Jump to navigation
Jump to search
The documentation for this module is not intended to be hosted on this wiki.
However, you might be able to find it at one of the following locations:
local a={}a.categories=""local b=require('Module:Plain text')._main;local c=require('Module:Arguments').getArgs;local d=require('Module:TableTools')function a.reverseTable(e)e[1],e[3]=e[3],e[1]return e end;function a.assign(f,g,h)local i;local j={}for k=0,h do if k==0 then i=""else i=tostring(k)end;j[k+1]=a.validate(b(f[g..i]))end;return j end;function a.shortdesc(l,m)return m:expandTemplate{title='Short description',args={l,'noreplace'}}end;function a.category(n)local o=string.format('[[Category:Pages using infobox settlement with bad %s]]',n)if o then a.categories=a.categories..o end end;function a.validate(p,q)if not p then return nil end;p=p:gsub('%b()',''):gsub('%s+',' '):gsub('^%s+',''):gsub('%s+$','')if p:match("[,;]")or not p:match("%a")then if q then a.category(q)end;return nil end;if p==""then return nil end;return p end;function a.cleanupLoc(r)if r==""then return nil end;local s={["England, United Kingdom"]="England",["Scotland, United Kingdom"]="Scotland",["Wales, United Kingdom"]="Wales",["New York City, New York, United States"]="New York City",["^United States$"]="the United States",["London, United Kingdom"]="London, England"}for k,t in pairs(s)do r=r:gsub(k,t)end;return r end;function a.main(m)local u=""local v={}local w={}local f=c(m,{parentOnly=true})local x=a.validate(b(f.settlement_type or f.type),"settlement type")or"Place"local y=b(f.short_description)v=a.assign(f,"subdivision_type",2)w=a.assign(f,"subdivision_name",2)if y then if y=='no'then return else local z=mw.language.getContentLanguage()return a.shortdesc(z:ucfirst(y),m)end end;if not(w[3]and(string.find(x,'[nN]eighbo[u]?rhood')or string.find(x,'[sS]uburb')))then w[3]=nil end;for A,B in ipairs(v)do local C={"Voivodeship"}for k,D in ipairs(C)do if w[A]and string.find(B,D,1,true)and not string.find(w[A],D,1,true)then w[A]=w[A].." "..D end end end;for A,B in ipairs(w)do if B then if string.find(x,B,1,true)then w[A]=nil;a.category("settlement type")end;if B==mw.title.getCurrentTitle().text then w[A]=nil end end end;local r=table.concat(d.compressSparseArray(a.reverseTable(w)),', ')r=a.cleanupLoc(r)if r then r=" in "..r else r=""end;local z=mw.language.getContentLanguage()return a.shortdesc(z:ucfirst(x..r),m)..a.categories end;return a