No edit summary |
No edit summary |
||
Line 6: | Line 6: | ||
function Location.make(countries, cities, title) | function Location.make(countries, cities, title) | ||
local container = mw.html.create('div') | local container = mw.html.create('div') | ||
local countryList = mw.text.split(countries, ',') | local countryList = mw.text.split(countries, ',') | ||
for i, v in ipairs(countryList) do | for i, v in ipairs(countryList) do | ||
v = mw.text.trim(v) | v = mw.text.trim(v) | ||
Line 37: | Line 17: | ||
local div = mw.html.create('div') | local div = mw.html.create('div') | ||
:wikitext(flag) | :wikitext(flag) | ||
:wikitext(mw.text.trim( | if cities then | ||
div:wikitext(mw.text.trim(mw.text.split(cities, ',')[i])) | |||
else | |||
div:wikitext(country) | |||
end | |||
container:node(div) | container:node(div) | ||
end | end |
Revision as of 09:07, 2 September 2022
Documentation for this module may be created at Module:Infobox/Widget/Location/doc
local CountryData = mw.loadData('Module:Localisation/Data')
local Flags = require('Module:Flags')
local String = require('Module:StringUtils')
local Location = {}
function Location.make(countries, cities, title)
local container = mw.html.create('div')
local countryList = mw.text.split(countries, ',')
for i, v in ipairs(countryList) do
v = mw.text.trim(v)
local country = CountryData[string.upper(v)]
local currentTitle = mw.title.getCurrentTitle().text
local gameCategory = mw.text.split(currentTitle, '/')[1]
local flag = Flags.icon(country, gameCategory)
local div = mw.html.create('div')
:wikitext(flag)
if cities then
div:wikitext(mw.text.trim(mw.text.split(cities, ',')[i]))
else
div:wikitext(country)
end
container:node(div)
end
return container
end
return Location