Changes

Jump to: navigation, search

Module:Template translation

261 bytes removed, 17:31, 10 June 2013
m
no edit summary
-- Get the last subpage (this function isolated for debugging purpose)
local subpage = mw.title.getCurrentTitle().subpageText
return --[[If the subpageis a valid language code, check if a translation of theend template exists in that language; if so, put it in langcode. Check first if there's an apostrophe, because they break the isKnownLanguageTag function this.isKnownLanguage(frame) ]] -- if (type(mw.ustring.match(this function isolated for debugging purposesubpage, "'")) == nil) return then if (mw.language.isKnownLanguageTag(frame.args[subpage)) then return subpage end end return 'language'])
end
 
function this.renderTranslatedTemplate(frame)
--[[If on a translation subpage (like Foobar/de), this function renders
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. Check first if there's an apostrophe, because they break the isKnownLanguageTag function. ]] if (type(mw.ustring.match(subpage, "~= ''")) == nil)
then
if (mw.language.isKnownLanguageTag(subpage)) then local translation = mw.title.new(template .. '/' .. subpage, namespace) if (translation.id ~= 0) then langcode = subpage end end
end
-- Copy args pseudo-table to a proper table so we can feed it to expandTemplate
Anonymous user

Navigation menu