Difference between revisions of "Module:Template translation"

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