Jump to content

Module:Interwiki extra

Permanently protected module
From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Mr. Stradivarius (talk | contribs) at 16:42, 4 August 2013 (make a start on an interwiki library). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
(diff) ← Previous revision | Latest revision (diff) | Newer revision → (diff)

-- This is the interwiki library. It is not meant to be used directly in articles, but to be used by other Lua modules.

local interwikiTable = mw.loadData( 'Module:InterwikiTable' )

local iw = {}

local function getProjectCode( prefix )
    for projectCode, projectVal in pairs( interwikiTable ) do
        for _, iwCode in ipairs( projectVal.iw_prefix ) do
            if iwCode == prefix then
                return projectCode
            end
        end
    end
    return nil
end

function iw.isKnownPrefix( prefix )
    return getProjectCode( prefix ) and true or false
end

return iw