Difference between revisions of "Module:Icon"

Jump to navigation Jump to search
221 bytes added ,  17:41, 23 February 2022
no edit summary
Line 2: Line 2:
local p = {}
local p = {}
local com = require('Module:Common')
local com = require('Module:Common')
require('Module:Icon/data')


local function _requirements(resource, value, link, text)
 
local function _requirements(resource, value, link, text, lang)
if string.lower(lang) == 'en' then
require('Module:Icon/en')
else
require('Module:Icon/en') -- if no language is supplied opr code is invalid, fallback to english
end
resource = string.lower(com.trim(resource))
resource = string.lower(com.trim(resource))
resource = iconList[resource]
resource = iconList[resource]
Line 50: Line 55:
l = frame.args['link']
l = frame.args['link']
t = frame.args[1]
t = frame.args[1]
return _requirements(r, v, l, t)
l = frame.args['lang']
return _requirements(r, v, l, t, l)
end
end


function p.icon(resource, value, link, text)
function p.icon(resource, value, link, text, lang)
return _requirements(resource, value, link, text)
return _requirements(resource, value, link, text, lang)
end
end


Line 67: Line 73:
for k, v in ipairs(list) do
for k, v in ipairs(list) do
vs = mw.text.split(v, '-')
vs = mw.text.split(v, '-')
result = result .. _requirements(vs[1], vs[2], nil, frame.args['text'])
result = result .. _requirements(vs[1], vs[2], nil, frame.args['text'], frame.args['lang'])
if k ~= table.getn(list) then
if k ~= table.getn(list) then
result = result .. '<br />'
result = result .. '<br />'
Line 77: Line 83:
end
end


function p.documentation()
function p.documentation(frame)
keys = {}
keys = {}
     for z in pairs(iconList) do
     for z in pairs(iconList) do
Line 98: Line 104:
dataTable[i] = dataTable[i]  
dataTable[i] = dataTable[i]  
.. '| ' .. v
.. '| ' .. v
.. ' || ' .. _requirements(v, '', '', '')  
.. ' || ' .. _requirements(v, '', '', '', '')  
.. ' || ' ..  iconList[v]['link']
.. ' || ' ..  iconList[v]['link']
.. '\n|-\n'
.. '\n|-\n'

Navigation menu