Difference between revisions of "Module:Template translation"

Jump to navigation Jump to search
m
Undid revision 3381029 by Shirayuki (talk)
en>Shirayuki
(add pagename parameter)
en>Shirayuki
m (Undid revision 3381029 by Shirayuki (talk))
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(pagename)
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
    --  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 title = (pagename or mw.title.getCurrentTitle().fullText)
     local titleparts = mw.text.split(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

Navigation menu