Module:Localisation

local p = {} local getArgs = require("Module:Arguments").getArgs

-- Get country name function p.getCountryName(frame) local args = getArgs(frame) return p._getCountryName(args, frame) end

function p._getCountryName(args, frame) local country = args[1] local noentry = args[2] or '' local data = mw.loadData('Module:Localisation/data/country') if (country == nil) then country = 'nocountry' end -- Remove whitespace country = mw.text.trim(country) -- Unstrip nowiki strip markers country = mw.text.unstripNoWiki(country)

-- Uppercase country = country:upper

-- First try to look it up	local countryname = data[country] -- Return message if none is found if (countryname == nil) then mw.log('No country found in Module:Localisation/data/country: ' .. country) -- set category unless second argument is set if noentry ~= '' then countryname = '' else countryname = (frame or mw.getCurrentFrame):expandTemplate{title = 'Flag/invalidcountry', args = {country}} end end return countryname end

return p