Changes

Jump to: navigation, search

Module:Template translation

408 bytes added, 23:31, 24 May 2013
add support for main-namespace transclusion for backcompat
local template = frame.args['template']
local langcode = '/en'
local namespace = 'Template:'
-- Get the last subpage
local subpage = mw.title.getCurrentTitle().subpageText
--[[ Check whether the template is actually in the Template namespace, or
if we're transcluding a main-namespace page.
(added for backward compatibility of Template:TNT)
]]
local templateFullTitle = mw.title.new( template, 'Template' )
if ( templateFullTitle.id == 0)
then
namespace=':'
end
--[[ If the subpage is a valid language code, check if a translation of the
if ( mw.language.isKnownLanguageTag( subpage ) )
then
local translation = mw.title.new( namespace..template..'/'..subpage, 'Template' )
if ( translation.id ~= 0)
then
-- Render the template
return frame:expandTemplate{ title = namespace..template..langcode, args = arguments }
end
return p
Anonymous user

Navigation menu