Toggle menu
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

Module:Documentation: Difference between revisions

From The Petit Planet Wiki
No edit summary
No edit summary
Line 36: Line 36:
local p = {}
local p = {}
p.i18n = i18n
p.i18n = i18n
-- Capitalizes first letter of strings
-- src: https://stackoverflow.com/questions/2421695/first-character-uppercase-lua
local function firstToUpper(str)
    return (str:gsub("^%l", string.upper))
end


-- --------------------------------------------------------------------------
-- --------------------------------------------------------------------------
Line 134: Line 140:
-- @return {string}
-- @return {string}
--]]
--]]
function p.resolveNamespace(subjectSpace, lowerPlural)
function p.resolveNamespace(subjectSpace, upperPlural)
if subjectSpace == 10 then -- Template namespace
if subjectSpace == 10 then -- Template namespace
if lowerPlural then return 'templates'
if upperPlural then return 'templates'
else return 'template' end
else return 'template' end
elseif subjectSpace == 828 then -- Module namespace
elseif subjectSpace == 828 then -- Module namespace
if lowerPlural then return 'modules'
if upperPlural then return 'modules'
else return 'module' end
else return 'module' end
elseif subjectSpace == 6 then -- File namespace
elseif subjectSpace == 6 then -- File namespace
if lowerPlural then return 'files'
if upperPlural then return 'files'
else return 'file' end
else return 'file' end
end
end
Line 808: Line 814:
if checkExists(env.docTitle.prefixedText) then
if checkExists(env.docTitle.prefixedText) then
tags[2] = lnkdta:tag('td')
tags[2] = lnkdta:tag('td')
tags[2]:wikitext('[[' .. env.docTitle.prefixedText .. '|' .. p.message('doc-link-display') .. ']]')
tags[2]:wikitext('[[' .. env.docTitle.prefixedText .. '|' .. firstToUpper(p.message('doc-link-display')) .. ']]')
colspan = colspan + 1
colspan = colspan + 1
end
end
if checkExists(env.sandboxTitle.prefixedText) then
if checkExists(env.sandboxTitle.prefixedText) then
tags[3] = lnkdta:tag('td')
tags[3] = lnkdta:tag('td')
tags[3]:wikitext('[[' .. env.sandboxTitle.prefixedText .. '|' .. i18n:msg('sandbox-link-display') .. ']]')
tags[3]:wikitext('[[' .. env.sandboxTitle.prefixedText .. '|' .. firstToUpper(i18n:msg('sandbox-link-display')) .. ']]')
colspan = colspan + 1
colspan = colspan + 1
end
end
Line 1,309: Line 1,315:
if templateTypes then
if templateTypes then
for _,Type in ipairs(templateTypes) do
for _,Type in ipairs(templateTypes) do
ret = ret .. p.makeCategoryLink(Type .. ' Templates')
ret = ret .. p.makeCategoryLink(Type .. ' templates')
end
end
end
end