Module:Documentation: Difference between revisions
Jump to navigation
Jump to search
m>Mr. Stradivarius i18n for the "editors can experiment" blurb |
m>Mr. Stradivarius finish i18n |
||
Line 34: | Line 34: | ||
cfg.sandboxSubpage = 'sandbox' -- The name of the template subpage typically used for sandboxes. | cfg.sandboxSubpage = 'sandbox' -- The name of the template subpage typically used for sandboxes. | ||
cfg.testcasesSubpage = 'testcases' -- The name of the template subpage typically used for test cases. | cfg.testcasesSubpage = 'testcases' -- The name of the template subpage typically used for test cases. | ||
cfg.printSubpage = 'Print' -- The name of the template subpage used for print versions. | |||
cfg.mainDivId = 'template-documentation' -- The "id" attribute of the main HTML "div" tag. | cfg.mainDivId = 'template-documentation' -- The "id" attribute of the main HTML "div" tag. | ||
cfg.mainDivClasses = 'template-documentation iezoomfix' -- The CSS classes added to the main HTML "div" tag. | cfg.mainDivClasses = 'template-documentation iezoomfix' -- The CSS classes added to the main HTML "div" tag. | ||
Line 78: | Line 79: | ||
cfg.testcasesEditLinkDisplay = 'edit' -- The text to display for test cases "edit" links. | cfg.testcasesEditLinkDisplay = 'edit' -- The text to display for test cases "edit" links. | ||
cfg.testcasesCreateLinkDisplay = 'create' -- The text to display for test cases "create" links. | cfg.testcasesCreateLinkDisplay = 'create' -- The text to display for test cases "create" links. | ||
cfg.docLinkDisplay = '/' .. cfg.docSubpage -- The text to display when linking to the /doc subpage. | |||
cfg.subpagesLinkDisplay = 'Subpages of this $1' -- The text to display for the "subpages of this page" link. $1 is cfg.templatePagetype, cfg.modulePagetype or cfg.defaultPagetype, depending on whether the current page is in the template namespace, the module namespace, or another namespace. | |||
cfg.printLinkDisplay = '/' .. cfg.printSubpage -- The text to display when linking to the /doc subpage. | |||
-- Sentences used in the end box. | -- Sentences used in the end box. | ||
Line 84: | Line 88: | ||
cfg.templatePossessive = "template's" -- Possessive case for "template". | cfg.templatePossessive = "template's" -- Possessive case for "template". | ||
cfg.modulePossessive = "module's" -- Possessive case for "module". | 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. | cfg.mirrorEditSummary = 'Create sandbox version of $1' -- The default edit summary to use when a user clicks the "mirror" link. $1 is a wikilink to the template page. | ||
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. If the page doesn't exist, the mirror link uses the edit summar cfg.mirrorEditSummary. $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. | |||
cfg.addCategoriesBlurb = 'Please add categories to the $1 subpage.' -- Text to direct users to add categories to the /doc subpage. Not used if the "content" or "docname fed" arguments are set, as then it is not clear where to add the categories. $1 is a link to the /doc subpage with a display value of cfg.docLinkDisplay. | |||
cfg.printBlurb = 'A [[Help:Books/for experts#Improving the book layout|print version]] of this template exists at $1. If you make a change to this template, please update the print version as well.' -- Text to display if a /Print subpage exists. $1 is a link to the subpage with a display value of cfg.printLinkDisplay. | |||
-- Other display settings | -- Other display settings | ||
Line 92: | Line 99: | ||
cfg.fileNamespaceHeading = 'Summary' -- The heading shown in the file namespace. | cfg.fileNamespaceHeading = 'Summary' -- The heading shown in the file namespace. | ||
cfg.otherNamespacesHeading = 'Documentation' -- The heading shown in other namespaces. | cfg.otherNamespacesHeading = 'Documentation' -- The heading shown in other namespaces. | ||
cfg.templatePagetype = 'template' -- The pagetype to display for template pages. | |||
cfg.modulePagetype = 'module' -- The pagetype to display for Lua module pages. | |||
cfg.defaultPagetype = 'page' -- The pagetype to display for pages other than templates or Lua modules. | |||
-- Category settings | |||
cfg.displayPrintCategory = true -- Set to true to enable output of cfg.printCategory if a /Print subpage exists. | |||
cfg.printCategory = 'Templates with print versions' -- Category to output if cfg.displayPrintCategory is set to true, and a /Print subpage exists. | |||
cfg.displayStrangeUsageCategory = true -- Set to true to enable output of cfg.strangeUsageCategory if the module is used on a /doc subpage or a /testcases subpage. | |||
cfg.strangeUsageCategory = 'Wikipedia pages with strange ((documentation)) usage' -- Category to output if cfg.displayStrangeUsageCategory is set to true and the module is used on a /doc subpage or a /testcases subpage. | |||
cfg.strangeUsageCategoryMainspaceSort = 'Main:' -- Category sort key prefix to use for cfg.strangeUsageCategory in the main namespace. The prefix is followed by the full page name. | |||
---------------------------------------------------------------------------- | ---------------------------------------------------------------------------- | ||
Line 141: | Line 158: | ||
return mw.ustring.format('[[%s]]', page) | return mw.ustring.format('[[%s]]', page) | ||
end | end | ||
end | |||
local function makeCategoryLink(cat, sort) | |||
local catns = mw.site.namespaces[14].name | |||
return makeWikilink(catns .. '/' .. cat, sort) | |||
end | end | ||
Line 438: | Line 460: | ||
local sandboxPreload = subjectSpace == 828 and cfg.moduleSandboxPreload or cfg.templateSandboxPreload | 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 = | local mirrorSummary = formatMessage(cfg.mirrorEditSummary, {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) | sandboxLinks = cfg.sandboxLinkDisplay .. ' ' .. makeToolbar(sandboxCreateLink, mirrorLink) | ||
Line 455: | Line 477: | ||
-- 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 | ||
local docPathLink = makeWikilink(docpage, cfg.docLinkDisplay) | |||
text = text .. formatMessage(cfg.addCategoriesBlurb, {docPathLink}) | |||
end | end | ||
-- Show the "subpages" link. | -- Show the "subpages" link. | ||
Line 461: | Line 484: | ||
local pagetype | local pagetype | ||
if subjectSpace == 10 then | if subjectSpace == 10 then | ||
pagetype = | pagetype = cfg.templatePagetype | ||
elseif subjectSpace == 828 then | elseif subjectSpace == 828 then | ||
pagetype = | pagetype = cfg.modulePagetype | ||
else | else | ||
pagetype = | pagetype = cfg.defaultPagetype | ||
end | end | ||
text = text .. ' ' .. makeWikilink('Special:PrefixIndex/' .. templatePage .. '/', | text = text .. ' ' .. makeWikilink('Special:PrefixIndex/' .. templatePage .. '/', formatMessage(cfg.subpagesLinkDisplay, {pagetype})) | ||
end | end | ||
-- Show the "print" link if it exists. | -- Show the "print" link if it exists. | ||
local printPage = templatePage .. '/ | local printPage = templatePage .. '/' .. cfg.printSubpage | ||
local printTitle = mw.title.new(printPage) | local printTitle = mw.title.new(printPage) | ||
if printTitle.exists then | if printTitle.exists then | ||
text = text .. '<br /> | local printLink = makeWikilink(printPage, cfg.printLinkDisplay) | ||
text = text .. '<br />' .. formatMessage(cfg.printBlurb, {printLink}) | |||
.. (cfg.displayPrintCategory and makeCategoryLink(cfg.printCategory) or '') | |||
end | end | ||
end | end | ||
Line 489: | Line 512: | ||
local ret = '' | local ret = '' | ||
local subpage = currentTitle.subpageText | local subpage = currentTitle.subpageText | ||
if subpage == cfg.docSubpage or subpage == cfg.testcasesSubpage then | if cfg.displayStrangeUsageCategory and (subpage == cfg.docSubpage or subpage == cfg.testcasesSubpage) then | ||
local sort = (currentTitle.namespace == 0 and | local sort = (currentTitle.namespace == 0 and cfg.strangeUsageCategoryMainspaceSort or '') .. currentTitle.prefixedText -- Sort on namespace. | ||
ret = ret .. | ret = ret .. makeCategoryLink(cfg.strangeUsageCategory, sort) | ||
end | end | ||
return ret | return ret |