Changes

Jump to: navigation, search

Module:Template translation

87 bytes added, 20:10, 10 June 2013
m
fix comments (there's no more any script errors)
if (string.find(subpage, "'", 1, true) == nil)
then
--[[If Return the subpage only if it 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
end
end
-- Otherwise there's currently no known language subpage
return ''
end
--[[If on a translation subpage (like Foobar/de), this function renders
a given template in the same language, if the translation is available.
Otherwise, the template is rendered in its default language, without
modification.
This is aimed at replacing the current implementation of Template:TNT.
]]
function this.renderTranslatedTemplate(frame)
--[[If on a translation subpage (like Foobar/de), this function renders
a given template in the same language, if the translation is available.
Otherwise, the template is rendered in its default language, without
modification.
This is aimed at replacing the current implementation of Template:TNT.
]]
local template = frame.args['template']
 
--[[Check whether the template is actually in the Template namespace, or
if we're transcluding a main-namespace page.
namespace = ''
end
local langcode = 'en'
-- Get the last subpage and check if it matches a known language code
local langcode = 'en' -- default language template subpage to render
local subpage = this.getLanguageSubpage()
if (subpage ~= '')
then
-- Check if a translation of the template exists in that language; if so, put it in langcode local translation = mw.title.new(namespace .. template .. '/' .. subpage, namespace)
if (translation.id ~= 0)
then
end
end
 
-- Copy args pseudo-table to a proper table so we can feed it to expandTemplate
-- Then render the template
local arguments = {}
for k, v in pairs(frame.args) do
arguments[k] = v
end
-- Render the template
return frame:expandTemplate{title = namespace .. ':' .. template .. '/' .. langcode, args = arguments}
end
return this
Anonymous user

Navigation menu