편집을 취소할 수 있습니다. 이 편집을 되돌리려면 아래의 바뀐 내용을 확인한 후 게시해주세요.
최신판 | 당신의 편집 | ||
36번째 줄: | 36번째 줄: | ||
and subpage ~= "sandbox" | and subpage ~= "sandbox" | ||
and subpage ~= "testcases" | and subpage ~= "testcases" | ||
then | then | ||
return subpage | return subpage | ||
50번째 줄: | 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 ib all namespaces where the Translate tool works. | |||
--[[This code does not work | |||
-- 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 | ||
-- It would not work in the main namespace of English Wikipedia (but the | -- It would not work in the main namespace of English Wikipedia (but the | ||
84번째 줄: | 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 | ||
108번째 줄: | 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 | ||
171번째 줄: | 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 | ||
189번째 줄: | 152번째 줄: | ||
if (subpage == '') | if (subpage == '') | ||
then | then | ||
subpage = this. | subpage = this.getLanguageSubpage() | ||
end | end | ||
if (subpage == '') | if (subpage == '') | ||
273번째 줄: | 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 |