Leaguepedia | League of Legends Esports Wiki
[checked revision][checked revision]
((via Mediawiker ST3))
(finalExtends)
 
(11 intermediate revisions by the same user not shown)
Line 1: Line 1:
local lang = mw.getLanguage('en')
+
local util_vars = require("Module:VarsUtil")
local COUNTRY_LOOKUP = mw.loadData('Module:Countrynames')
 
local DEFAULT = {
 
name = 'Unrecognized Country![[Category:Unrecognized Country]]',
 
adjective = 'Unrecognized Country![[Category:Unrecognized Country]]',
 
flag = 'Unrecognized Country![[Category:Unrecognized Country]]',
 
the = false
 
}
 
   
  +
local p = require('Module:EntityAbstract'):finalExtends()
function countryLookup(str)
 
local str_lc = lang:lc(str)
+
local h = {}
local vars = COUNTRY_LOOKUP[str_lc]
 
if not vars then
 
return DEFAULT
 
end
 
if type(vars) == 'string' then
 
vars = COUNTRY_LOOKUP[vars]
 
end
 
return vars
 
end
 
   
  +
p.objectType = 'Country'
local p = {}
 
  +
p.imagelength = 'name'
  +
p.defaultlength = 'name'
  +
p.cssClass = 'country-object'
  +
p.imagesizes = {}
  +
p.nosize = true
   
function p.debug(str)
+
function p:name(opts)
  +
if self.is_nil then return nil end
local vars = countryLookup(str)
 
 
if not opts then opts = {} end
local tbl = {
 
  +
if not opts.the then return self:super('name', opts) end
'cat'
 
  +
if not self.vars.the then return self:super('name', opts) end
}
 
  +
return ('the ') .. self:super('name', opts)
for k, v in pairs(vars) do
 
if type(v) == 'string' then
 
tbl[#tbl+1] = v
 
end
 
end
 
return table.concat(tbl,',')
 
end
 
 
function p.main(frame)
 
local args = frame
 
if frame == mw.getCurrentFrame() then
 
args = require('Module:ProcessArgs').merge(true)
 
else
 
frame = mw.getCurrentFrame()
 
end
 
 
if not args[1] or args[1] == '' then
 
return ''
 
end
 
local style = args[2] or 'default'
 
 
return p[style](args[1])
 
end
 
 
function p.default(str)
 
local vars = countryLookup(str)
 
return vars.name
 
end
 
 
function p.rightlong(str)
 
local vars = countryLookup(str)
 
if vars.flag then
 
return string.format('[[File:%s.png|%s|link=]] %s',
 
vars.flag,
 
vars.name,
 
vars.name
 
)
 
end
 
return vars.name
 
end
 
 
function p.localization(str)
 
local vars = countryLookup(str)
 
return vars.adjective
 
end
 
 
function p.onlyimage(str)
 
local vars = countryLookup(str)
 
return vars.flag and string.format(
 
'[[File:%s.png|%s|link=]]',
 
vars.flag,
 
vars.name
 
) or ''
 
end
 
 
function p.namethe(str)
 
local vars = countryLookup(str)
 
return (vars.the and 'the ' or '') .. (vars.name or '')
 
 
end
 
end
   

Latest revision as of 05:41, 24 August 2020

Edit the documentation or categories for this module.


local util_vars = require("Module:VarsUtil")

local p = require('Module:EntityAbstract'):finalExtends()
local h = {}

p.objectType = 'Country'
p.imagelength = 'name'
p.defaultlength = 'name'
p.cssClass = 'country-object'
p.imagesizes = {}
p.nosize = true

function p:name(opts)
	if self.is_nil then return nil end
	if not opts then opts = {} end
	if not opts.the then return self:super('name', opts) end
	if not self.vars.the then return self:super('name', opts) end
	return ('the ') .. self:super('name', opts)
end

return p