Module:Template translation: Difference between revisions
Mediawiki>Shirayuki add exceptions for Help:Subpages/subpage and friends |
Richardpruen (talk | contribs) m 1 revision imported |
||
Line 36: | Line 36: | ||
and subpage ~= "sandbox" | and subpage ~= "sandbox" | ||
and subpage ~= "testcases" | and subpage ~= "testcases" | ||
then | then | ||
return subpage | return subpage | ||
Line 50: | Line 43: | ||
end | end | ||
--[[Get the last subpage of | --[[Get the last subpage of the current page if it is a translation. | ||
]] | ]] | ||
function this. | function this.getLanguageSubpage() | ||
--[[This code does not work in all namespaces where the Translate tool works. | --[[This code does not work in all namespaces where the Translate tool works. | ||
-- It works in the main namespace on Meta because it allows subpages there | -- It works in the main namespace on Meta because it allows subpages there | ||
Line 84: | Line 58: | ||
-- bug of Meta-Wiki. The work-around is to split the full title and then | -- bug of Meta-Wiki. The work-around is to split the full title and then | ||
-- get the last titlepart. | -- get the last titlepart. | ||
local subpage = title.subpageText | local subpage = mw.title.getCurrentTitle().subpageText | ||
--]] | --]] | ||
local titleparts = mw.text.split(mw.title.getCurrentTitle().fullText, '/') | |||
local subpage = titleparts[#titleparts] | |||
return this.checkLanguage(subpage, '') | |||
end | end | ||
Line 108: | Line 69: | ||
]] | ]] | ||
function this.getFrameLanguageSubpage(frame) | function this.getFrameLanguageSubpage(frame) | ||
local titleparts = mw.text.split(frame:getParent():getTitle(), '/') | |||
local subpage = titleparts[#titleparts] | |||
return this.checkLanguage(subpage, '') | |||
end | end | ||
Line 171: | Line 134: | ||
]] | ]] | ||
local title | local title | ||
local namespace = args[' | local namespace = args['namespace'] or '' | ||
if (namespace ~= '') -- Checks for | if (namespace ~= '') -- Checks for namespace parameter for custom ns. | ||
then | then | ||
title = this.title(namespace, pagename) -- Costly | title = this.title(namespace, pagename) -- Costly | ||
Line 189: | Line 152: | ||
if (subpage == '') | if (subpage == '') | ||
then | then | ||
subpage = this. | subpage = this.getLanguageSubpage() | ||
end | end | ||
if (subpage == '') | if (subpage == '') | ||
Line 273: | Line 236: | ||
end | end | ||
arguments['template'] = title -- override the existing parameter of the base template name supplied with the full name of the actual template expanded | arguments['template'] = title -- override the existing parameter of the base template name supplied with the full name of the actual template expanded | ||
arguments[' | arguments['namespace'] = nil -- discard the specified namespace override | ||
arguments['uselang'] = args['uselang'] -- argument forwarded into parent frame | arguments['uselang'] = args['uselang'] -- argument forwarded into parent frame | ||
arguments['noshift'] = args['noshift'] -- argument forwarded into parent frame | arguments['noshift'] = args['noshift'] -- argument forwarded into parent frame | ||
return frame:expandTemplate{title = ':' .. title, args = arguments} | return frame:expandTemplate{title = ':' .. title, args = arguments} | ||
end | end | ||
return this | return this |