Difference between revisions of "Module:Languages"
Jump to navigation
Jump to search
m |
m |
||
Line 16: | Line 16: | ||
:attr("lang", lang) | :attr("lang", lang) | ||
:wikitext("[[:", title, "|", parsedLang, "]]") | :wikitext("[[:", title, "|", parsedLang, "]]") | ||
− | return "{{#ifexist:" .. title .. "| • " .. bdi .. "}}" | + | return "{{#ifexist:" .. title .. "| • " .. tostring(bdi) .. "}}" |
end | end | ||
Revision as of 07:59, 10 April 2017
local p = {}
local HtmlBuilder = require("Module:HtmlBuilder") local getArgs = require("Module:Arguments").getArgs local headers = mw.loadData('Module:Languages/headers')
function p.languages(frame)
local args = getArgs(frame, {inherited = true}) return p._languages(args)
end
local function getLangText(title, lang)
title = title .. "/" .. lang local parsedLang = "" .. lang .. "" local bdi = HtmlBuilder.create("bdi") :attr("lang", lang) :wikitext("", parsedLang, "") return ""
end
function p._languages(args)
local titleObj = mw.title.getCurrentTitle() local title = args[1] or titleObj.nsText .. ":" .. titleObj.baseText local currLang = titleObj.subpageText if currLang == titleObj.text then currLang = "en" end local header = headers[currLang] or "Language:" local text = "English" for lang, _ in pairs(headers) do text = text .. getLangText(title, lang) end
return "
" .. header .. " | " .. text .. " |
---|
"
end
return p