Module:Documentation: Difference between revisions
i18n for the "editors can experiment" blurb
m>Mr. Stradivarius (create a formatMessage function for formatting cfg messages in an arbitrary order) |
m>Mr. Stradivarius (i18n for the "editors can experiment" blurb) |
||
Line 42: | Line 42: | ||
cfg.startBoxLinkclasses = 'mw-editsection plainlinks' -- The CSS classes used for the [view][edit][history] or [create] links in the start box. | cfg.startBoxLinkclasses = 'mw-editsection plainlinks' -- The CSS classes used for the [view][edit][history] or [create] links in the start box. | ||
cfg.startBoxLinkId = 'doc_editlinks' -- The HTML "id" attribute for the links in the start box. | cfg.startBoxLinkId = 'doc_editlinks' -- The HTML "id" attribute for the links in the start box. | ||
cfg.fileDocpagePreload = 'Template:Documentation/preload-filespace' -- | cfg.fileDocpagePreload = 'Template:Documentation/preload-filespace' -- Preload file for documentation page in the file namespace. | ||
cfg.docpagePreload = 'Template:Documentation/preload-filespace' -- | cfg.docpagePreload = 'Template:Documentation/preload-filespace' -- Preload file for template documentation pages in all namespaces. | ||
cfg.modulePreload = 'Template:Documentation/preload-module-doc' -- | cfg.modulePreload = 'Template:Documentation/preload-module-doc' -- Preload file for Lua module documentation pages. | ||
cfg.templateSandboxPreload = 'Template:Documentation/preload-sandbox' -- Preload file for template sandbox pages. | |||
cfg.moduleSandboxPreload = 'Template:Documentation/preload-module-sandbox' -- Preload file for Lua module sandbox pages. | |||
cfg.templateTestcasesPreload = 'Template:Documentation/preload-testcases' -- Preload file for template test cases pages. | |||
cfg.moduleTestcasesPreload = 'Template:Documentation/preload-module-testcases' -- Preload file for Lua module test cases pages. | |||
-- Settings for the {{fmbox}} template. | -- Settings for the {{fmbox}} template. | ||
Line 55: | Line 59: | ||
cfg.fmboxStyle = 'background-color: #ecfcf4' -- The value sent to the style parameter of {{fmbox}}. | cfg.fmboxStyle = 'background-color: #ecfcf4' -- The value sent to the style parameter of {{fmbox}}. | ||
cfg.fmboxTextstyleParam = 'textstyle' -- The name of the "textstyle" parameter of {{fmbox}}. | cfg.fmboxTextstyleParam = 'textstyle' -- The name of the "textstyle" parameter of {{fmbox}}. | ||
cfg.fmboxTextstyle = 'font-style: italic | cfg.fmboxTextstyle = 'font-style: italic' -- The value sent to the "textstyle parameter of {{fmbox}}. | ||
-- Display settings | -- Display settings | ||
Line 76: | Line 80: | ||
-- Sentences used in the end box. | -- Sentences used in the end box. | ||
cfg. | cfg.transcludedFromBlurb = 'The above [[Wikipedia:Template documentation|documentation]] is [[Wikipedia:Transclusion|transcluded]] from $1.' -- Notice displayed when the docs are transcluded from another page. $1 is a wikilink to that page. | ||
cfg. | cfg.createModuleDocBlurb = 'You might want to $1 a documentation page for this [[Wikipedia:Lua|Scribunto module]].' -- Notice displayed in the module namespace when the documentation subpage does not exist. $1 is a link to create the documentation page with the preload cfg.modulePreload and the display cfg.createLinkDisplay. | ||
cfg.templatePossessive = "template's" -- Possessive case for "template". | |||
cfg.modulePossessive = "module's" -- Possessive case for "module". | |||
cfg.experimentBlurb = 'Editors can experiment in this $1 $2 and $3 pages.' -- Text inviting editors to experiment in sandbox and test cases pages. It is only shown in the template and module namespaces. $1 is cfg.templatePossessive or cfg.modulePossessive depending on what namespace we are in. $2 is a link to the sandbox in the format "cfg.sandboxLinkDisplay (cfg.sandboxEditLinkDisplay | cfg.compareLinkDisplay)" if the sandbox exists, and the format "cfg.sandboxLinkDisplay (cfg.sandboxCreateLinkDisplay | cfg.mirrorLinkDisplay)" if the sandbox doesn't exist. If the sandbox link doesn't exist, the create link preloads the page with cfg.templateSandboxPreload or cfg.moduleSandboxPreload depending on the current namespace. $3 is a link to the test cases page in the format "cfg.testcasesLinkDisplay (cfg.testcasesEditLinkDisplay)" if the test cases page exists, and in the format "cfg.testcasesLinkDisplay (cfg.testcasesCreateLinkDisplay)" if the test cases page doesn't exist. If the test cases page doesn't exist, the create link preloads the page with cfg.templateTestcasesPreload or cfg.moduleTestcasesPreload depending on the current namespace. | |||
-- Other display settings | -- Other display settings | ||
Line 411: | Line 418: | ||
local editLink = makeUrlLink(docTitle:fullUrl{action = 'edit'}, cfg.editLinkDisplay) | local editLink = makeUrlLink(docTitle:fullUrl{action = 'edit'}, cfg.editLinkDisplay) | ||
local historyLink = makeUrlLink(docTitle:fullUrl{action = 'history'}, cfg.historyLinkDisplay) | local historyLink = makeUrlLink(docTitle:fullUrl{action = 'history'}, cfg.historyLinkDisplay) | ||
text = text .. formatMessage(cfg. | text = text .. formatMessage(cfg.transcludedFromBlurb, {docLink}) .. ' ' .. makeToolbar(editLink, historyLink) .. '<br />' | ||
elseif subjectSpace == 828 then | elseif subjectSpace == 828 then | ||
-- /doc does not exist; ask to create it. | -- /doc does not exist; ask to create it. | ||
local createLink = makeUrlLink(docTitle:fullUrl{action = 'edit', preload = cfg.modulePreload}, cfg.createLinkDisplay) | local createLink = makeUrlLink(docTitle:fullUrl{action = 'edit', preload = cfg.modulePreload}, cfg.createLinkDisplay) | ||
text = text .. formatMessage(cfg. | text = text .. formatMessage(cfg.createModuleDocBlurb, {createLink}) .. '<br />' | ||
end | end | ||
-- Add links to /sandbox and /testcases when appropriate. | -- Add links to /sandbox and /testcases when appropriate. | ||
if subjectSpace == 2 or subjectSpace == 828 or subjectSpace == 10 then | if subjectSpace == 2 or subjectSpace == 828 or subjectSpace == 10 then | ||
-- We are in the user, module or template namespaces. | -- We are in the user, module or template namespaces. | ||
local pagePossessive = subjectSpace == 828 and | local sandboxLinks, testcasesLinks | ||
local pagePossessive = subjectSpace == 828 and cfg.modulePossessive or cfg.templatePossessive | |||
local sandboxTitle = mw.title.new(sandbox) | local sandboxTitle = mw.title.new(sandbox) | ||
if sandboxTitle.exists then | if sandboxTitle.exists then | ||
Line 427: | Line 434: | ||
local sandboxEditLink = makeUrlLink(sandboxTitle:fullUrl{action = 'edit'}, cfg.sandboxEditLinkDisplay) | local sandboxEditLink = makeUrlLink(sandboxTitle:fullUrl{action = 'edit'}, cfg.sandboxEditLinkDisplay) | ||
local compareLink = makeUrlLink(mw.title.new('Special:ComparePages'):fullUrl{page1 = templatePage, page2 = sandbox}, cfg.compareLinkDisplay) | local compareLink = makeUrlLink(mw.title.new('Special:ComparePages'):fullUrl{page1 = templatePage, page2 = sandbox}, cfg.compareLinkDisplay) | ||
sandboxLinks = sandboxLink .. ' ' .. makeToolbar(sandboxEditLink, compareLink) | |||
else | else | ||
local sandboxPreload = | local sandboxPreload = subjectSpace == 828 and cfg.moduleSandboxPreload or cfg.templateSandboxPreload | ||
local sandboxCreateLink = makeUrlLink(sandboxTitle:fullUrl{action = 'edit', preload = sandboxPreload}, cfg.sandboxCreateLinkDisplay) | local sandboxCreateLink = makeUrlLink(sandboxTitle:fullUrl{action = 'edit', preload = sandboxPreload}, cfg.sandboxCreateLinkDisplay) | ||
local mirrorSummary = 'Create sandbox version of ' .. makeWikilink(templatePage) | local mirrorSummary = 'Create sandbox version of ' .. makeWikilink(templatePage) | ||
local mirrorLink = makeUrlLink(sandboxTitle:fullUrl{action = 'edit', preload = templatePage, summary = mirrorSummary}, cfg.mirrorLinkDisplay) | local mirrorLink = makeUrlLink(sandboxTitle:fullUrl{action = 'edit', preload = templatePage, summary = mirrorSummary}, cfg.mirrorLinkDisplay) | ||
sandboxLinks = cfg.sandboxLinkDisplay .. ' ' .. makeToolbar(sandboxCreateLink, mirrorLink) | |||
end | end | ||
local testcaseTitle = mw.title.new(testcases) | local testcaseTitle = mw.title.new(testcases) | ||
if testcaseTitle.exists then | if testcaseTitle.exists then | ||
local testcasesLink = makeWikilink(testcases, cfg.testcasesLinkDisplay) | local testcasesLink = makeWikilink(testcases, cfg.testcasesLinkDisplay) | ||
local testcasesEditLink = makeUrlLink(testcaseTitle:fullUrl{action = 'edit'}, cfg.testcasesEditLinkDisplay) | local testcasesEditLink = makeUrlLink(testcaseTitle:fullUrl{action = 'edit'}, cfg.testcasesEditLinkDisplay) | ||
testcasesLinks = testcasesLink .. ' ' .. makeToolbar(testcasesEditLink) | |||
else | else | ||
local testcasesPreload = | local testcasesPreload = subjectSpace == 828 and cfg.moduleTestcasesPreload or cfg.templateTestcasesPreload | ||
local testcasesCreateLink = makeUrlLink(testcaseTitle:fullUrl{action = 'edit', preload = testcasesPreload}, cfg.testcasesCreateLinkDisplay) | local testcasesCreateLink = makeUrlLink(testcaseTitle:fullUrl{action = 'edit', preload = testcasesPreload}, cfg.testcasesCreateLinkDisplay) | ||
testcasesLinks = cfg.testcasesLinkDisplay .. ' ' .. makeToolbar(testcasesCreateLink) | |||
end | end | ||
text = text .. ' | text = text .. formatMessage(cfg.experimentBlurb, {pagePossessive, sandboxLinks, testcasesLinks}) .. '<br />' | ||
-- Show the categories text, but not if "content" fed or "docname fed" since then it is unclear where to add the categories. | -- Show the categories text, but not if "content" fed or "docname fed" since then it is unclear where to add the categories. | ||
if not content and not docnameFed then | if not content and not docnameFed then |