Changes

Module:Template translation

68 bytes added, 17:20, 10 June 2013
m
no edit summary
]]
local template = frame.args['template']
local langcode = '/en'
local namespace = 'Template:'
-- Get the last subpage
local subpage = this.getLanguageSubpage()
--[[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 namespace = 'Template' local templateFullTitle = mw.title.new(template, 'Template'namespace)
if (templateFullTitle.id == 0)
then-- not found in the Template namespace, assume the main namespace namespace = ':'
end
 
local langcode = 'en'
-- Get the last subpage
local subpage = this.getLanguageSubpage()
--[[If the subpage is a valid language code, check if a translation of the
template exists in that language; if so, put it in langcode.
if (mw.language.isKnownLanguageTag(subpage))
then
local translation = mw.title.new(namespace .. template .. '/' .. subpage, namespace)
if (translation.id ~= 0)
then
langcode = '/' .. subpage
end
end
end
-- Render the template
return frame:expandTemplate{title = namespace .. ':' .. template .. '/' .. langcode, args = arguments}
end
return this
Anonymous user