Module:Special page interlanguage links/sandbox
This is the module sandbox page for Module:Special page interlanguage links (diff). See also the companion subpage for test cases (run). |
Warning: | This page is shared between multiple wikis. All changes to this page will be automatically copied to all wikis listed in the left side bar. To avoid unnecessary page regeneration and server load, changes should be tested on the page's sandbox. |
Module Quality
editModule:Special page interlanguage links | success: 1, error: 0, skipped: 0 |
Module:Special page interlanguage links/sandbox | success: 1, error: 0, skipped: 0 |
Documentation
editThis module allows displaying interlanguage links to all existing languages on special pages. It’s a custom to show such interlanguage links on Special:RecentChanges, but it can be used on any other special page as well that exists on all wikis of that project.
Functions
editp.main(frame)
edit
{{#invoke:Special page interlanguage links|main|RecentChanges}}
p._main(specialPageName)
edit
local interlanguageLinks = p._main('RecentChanges')
local p = {}
function p._main(specialPageName)
local links = {}
for n, _ in pairs(mw.site.interwikiMap('local')) do
if mw.language.isKnownLanguageTag(n) then
table.insert(links, string.format('[[%s:Special:%s]]', n, specialPageName))
end
end
table.sort(links)
return table.concat(links)
end
function p.main(frame)
return p._main(frame.args[1])
end
return p