Difference between revisions of "Module:Template translation"

Jump to navigation Jump to search
m
no edit summary
en>Verdy p
m (fix the script error when TNT is used on a pagename still without any /en subpage)
en>Verdy p
m
Line 86: Line 86:
     -- Get the last subpage and check if it matches a known language code.
     -- Get the last subpage and check if it matches a known language code.
     local subpage = this.getLanguageSubpage()
     local subpage = this.getLanguageSubpage()
     if (subpage ~= '')
     if (subpage == '')
     then
     then
        -- Check if a translation of the pagename exists in English
        local newtitle = mw.title.new(title.prefixedText .. '/' .. 'en') -- Costly
        -- Use the translation when it exists
        if (newtitle.id ~= 0)
        then
            title = newtitle
        end
    else
         -- Check if a translation of the pagename exists in that language
         -- Check if a translation of the pagename exists in that language
         local newtitle = mw.title.new(title.prefixedText .. '/' .. subpage) -- Costly
         local newtitle = mw.title.new(title.prefixedText .. '/' .. subpage) -- Costly
Anonymous user

Navigation menu