Module:Languages

Documentation for this module may be created at Module:Languages/doc

local p = {}

local function has_page(tab, lang)
    for _, value in ipairs(tab) do
        if value == lang then
            return true
        end
    end
    return false
end

function p.generate(frame)
    local languagesData = mw.loadData('Module:Languages/data')
    local parent = frame:getParent()
    local links = {}

    for _, lang in ipairs(languagesData) do
        local link = frame:expandTemplate{
            title = 'Languages/Lang',
            args = { lang }
        }
        table.insert(links, link)
    end

    return table.concat(links, '')
end

function p.main(frame)
    local languagesData = mw.loadData('Module:Languages/data')
    if has_page(languagesData, 'fr') then
        return "Yes"
    else
        return "No"
    end
end

return p