Module:Language link
Jump to navigation
Jump to search
Module version of {{Language link}}
allowing easy linking in modules for translation projects.
Usage[edit source]
local ll = require('Module:Language link').main
-- Parameters
ll('Link (Required)', 'Text (Optional)', 'Plain (Optional)')
-- Examples
ll('Zombi') --> [[Minecraft Wiki:Projects/Finnish translation/Zombi|Zombi]]
ll('Zombi', 'Zombit') --> [[Minecraft Wiki:Projects/Finnish translation/Zombi|Zombit]]
ll('Zombi', '', true) --> Minecraft Wiki:Projects/Finnish translation/Zombi
[view] [edit] [history] [refresh]The above documentation is transcluded from Module:Language link/doc.
require('strict')
local p = {}
local title = mw.title.getCurrentTitle()
local namespace = mw.site.namespaces.Project.name
function p.main(link, text, plain)
assert(link, "bad argument #1 for 'link' (string expected, got nil)")
local display = text and text or link
local page = title.baseText
:gsub('^Projects/', '')
local subpage = string.find(page, '/')
if subpage then
page = string.sub(page, 1, subpage - 1)
end
if plain then
return string.format('%s:Projects/%s/%s', namespace, page, link)
end
return string.format('[[%s:Projects/%s/%s|%s]]', namespace, page, link, display)
end
return p