Module:Template translation: Difference between revisions

add pagename parameter
(add some more forbidden language codes from {{pagelang}})
(add pagename parameter)
Line 47:
--[[Get the last subpage of the current page if it is a translation.
]]
function this.getLanguageSubpage(pagename)
--[[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 would not work in the main namespace of English Wikipedia (but the
-- articles are monolignual on that wiki).
-- On Meta-Wiki the main space uses subpages and its pages are translated.
-- The Translate tool allows translatng pages in all namespaces, even if
-- the namespace officially does not have subpages.
-- On Meta-Wiki the Category namespace still does not have subpages enabled,
-- even if they would be very useful for categorizing templates, that DO have
-- subpages (for documentatio and tstboxes pages). This is a misconfiguration
-- bug of Meta-Wiki. The work-around is to split the full title and then
-- get the last titlepart.
local subpage = mw.title.getCurrentTitle().subpageText
--]]
local titlepartstitle = mw.text.split(pagename or mw.title.getCurrentTitle().fullText, '/')
local titleparts = mw.text.split(title, '/')
local subpage = titleparts[#titleparts]
return this.checkLanguage(subpage, '')