Jump to content

Module:Template translation: Difference between revisions

m
hope this fixes this dummy bug of namespaces
m (preserve the namespace as it is resolved when testing other languages (may be needed for te main namespace) - workaround)
m (hope this fixes this dummy bug of namespaces)
Line 78:
title = mw.title.new(pagename, namespace) -- Costly
end
end
-- At this point the title should exist, otherwise render a red link to the missing page
if (title.id == 0)
then
return '[[' .. title.prefixedText .. ']]'
end
Line 91 ⟶ 85:
then
-- Check if a translation of the pagename exists in English
local newtitle = mw.title.new(title.prefixedTextpagename .. '/' .. 'en', namespace) -- Costly
-- Use the translation when it exists
if (newtitle.id ~= 0)
Line 99 ⟶ 93:
else
-- Check if a translation of the pagename exists in that language
local newtitle = mw.title.new(title.prefixedTextpagename .. '/' .. subpage, namespace) -- Costly
if (newtitle.id == 0)
then
-- Check if a translation of the pagename exists in English
newtitle = mw.title.new(title.prefixedTextpagename .. '/' .. 'en', namespace) -- Costly
end
-- Use the translation when it exists
Line 110 ⟶ 104:
title = newtitle
end
end
-- At this point the title should exist, otherwise render a red link to the missing page (resolved in its assumed namespace)
if (title.id == 0)
then
return '[[' .. title.prefixedText .. ']]'
end
Line 128:
end
end
return frame:expandTemplate{title = title, args = arguments}
end
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.