Module:Configuration list entry: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
m (1 revision imported) |
(No difference)
|
Latest revision as of 15:26, 12 July 2020
local p = {} local thisLang = require("Module:Template translation").getCurrentLanguageSubpage() function p._main(name) local frame = mw.getCurrentFrame() local translatedPage, translatedText -- reimplementing [[Module:Template translation]]'s getTranslatedTemplate function here to avoid expensive parser function -- call limits if thisLang ~= nil then -- try translation translatedPage = "Manual:$" .. name .. "/" .. thisLang translatedText = mw.title.new(translatedPage):getContent() end if translatedText == nil then -- try English translatedPage = "Manual:$" .. name .. "/en" translatedText = mw.title.new(translatedPage):getContent() end if translatedText == nil then -- try base page in case a configuration setting is not translatable at all translatedPage = "Manual:$" .. name translatedText = mw.title.new(translatedPage):getContent() end if translatedText == nil then error("Bogus configuration variable: $" .. name) end local summary = translatedText:match("\n%s*|%s*summary%s*=%s*([^\n]*)\n") local removed = translatedText:match("\n%s*|%s*version_max%s*=%s*([^|\n]-)%.?0?\n") local deprecated = translatedText:match("\n%s*|%s*version_deprecated%s*=%s*([^|\n]-)%.?0?\n") if summary then summary = " – " .. summary if removed and removed ~= "" then local num = tonumber(removed) if num and num < 1.19 then error("$" .. name .. " was removed before 1.19, so shouldn't be listed.") end summary = frame:expandTemplate{title="removed-inline",args={removed}} .. summary elseif deprecated and deprecated ~= "" then summary = frame:expandTemplate{title="deprecated-inline",args={deprecated}} .. summary end else error("Could not find summary for $" .. name) end return frame:preprocess(summary) end function p.main(frame) return p._main(frame.args.name) end return p;