Anonymous user
Module:Template translation: Difference between revisions
m
supplement for TNTN (to be used to solve self-recursions of TNT, with translatable templates trying to transclude other translatable templates also with TNT)
m (arguments still need to be copied (they are not a proper table)) |
m (supplement for TNTN (to be used to solve self-recursions of TNT, with translatable templates trying to transclude other translatable templates also with TNT)) |
||
Line 109:
end
--[[If on a translation subpage (like Foobar/de), this function
a given template in the same language, if the translation is available.
Otherwise, the template is
modification.
This is aimed at replacing the current implementation of Template:
This version does not expand the returned template name: this solves the
problem of self-recursion in TNT when translatable templates need themselves
to transclude other translable templates (such as Tnavbar).
]]
function this.
local args = frame.args
local pagename = args['template']
Line 167 ⟶ 171:
end
end
-- At this point the title should exist
return title.prefixedText, title.id ~= nil
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.
Note that translatable templates cannot transclude themselves other
-- At this point the title should exist, otherwise render a red link to the missing page (resolved in its assumed namespace)▼
translatable templates, as it will recurse on TNT. Use TNTN instead
to return only the effective template name to expand externally, with
template parameters also provided externally.
return '[[' .. title.prefixedText .. ']]'▼
function this.renderTranslatedTemplate(frame)
local title, found = this.getTranslatedTemplate(frame)
-- At this point the title should exist prior to performing the expansion
▲ --
-- (resolved in its assumed namespace). If we don't tet this here, a
-- script error would be thrown. Returning a red link is consistant with
-- MediaWiki behavior when attempting to transclude inexistant templates.
if not found then
end
-- Copy args pseudo-table to a proper table so we can feed it to expandTemplate.
-- Then render the pagename.
Line 199 ⟶ 222:
end
end
arguments['template'] = title
arguments['namespace'] = nil -- discard the specified namespace override
arguments['uselang'] = args['uselang'] -- argument forwarded into parent frame
arguments['noshift'] = args['noshift'] -- argument forwarded into parent frame
return frame:expandTemplate{title = ':' .. title
end
|