Module:Interwiki extra
Appearance
![]() | This module is rated as alpha. It is ready for third-party input, and may be used on a few pages to see if problems arise, but should be watched. Suggestions for new features or changes in their input and output mechanisms are welcome. |
![]() | This module is subject to page protection. It is a highly visible module in use by a very large number of pages, or is substituted very frequently. Because vandalism or mistakes would affect many pages, and even trivial editing might cause substantial load on the servers, it is protected from editing. |
Usage
{{#invoke:Interwiki extra|interwiki}}
See also {{Interwiki extra}} — wrapper.
Pages that use this module to add additional interwiki links are contained in the tracking category Category:Module:Interwiki extra: additional interwiki links (1,134).
-- This module provides functions and objects for dealing with interwiki links.
local checkType = require('libraryUtil').checkType
local interwikiData = mw.loadData('Module:Interwiki/data')
--------------------------------------------------------------------------------
-- Prefix class
--------------------------------------------------------------------------------
local Prefix = {}
Prefix.__index = Prefix
function Prefix.new(code)
checkType('Prefix.new', 1, code, 'string')
local obj = setmetatable({}, Prefix)
local data = interwikiData.prefixes[code]
if not data then
return nil
end
for k, v in pairs(data) do
obj[k] = v
end
return obj
end
function Prefix:makeUrl(page)
-- Interlanguage links are wiki-encoded (spaces are encoded as underbars),
-- even if the page is not a wiki and it doesn't make sense on that site.
page = mw.uri.encode(page, 'WIKI')
return mw.message.newRawMessage(self.url, page):plain()
end
return Prefix