Difference between revisions of "Module:Template translation"
Module:Template translation (view source)
Revision as of 20:40, 12 January 2014
, 20:40, 12 January 2014preserve the namespace as it is resolved when testing other languages (may be needed for te main namespace) - workaround
>Verdy p m (Undo revision 7059330 by Techman224 (talk) sorry but I need to see the error, because the revert breaks other pages) |
>Verdy p m (preserve the namespace as it is resolved when testing other languages (may be needed for te main namespace) - workaround) |
||
Line 71: | Line 71: | ||
title = mw.title.new(pagename, namespace) -- Costly | title = mw.title.new(pagename, namespace) -- Costly | ||
else -- Supposes that set page is in ns10. | else -- Supposes that set page is in ns10. | ||
title = mw.title.new(pagename, | namespace = 'Template' | ||
title = mw.title.new(pagename, namespace) -- Costly | |||
if (title.id == 0) | if (title.id == 0) | ||
then -- not found in the Template namespace, assume the main namespace (for backward compatibility) | then -- not found in the Template namespace, assume the main namespace (for backward compatibility) | ||
title = mw.title.new(pagename, | namespace = '' | ||
title = mw.title.new(pagename, namespace) -- Costly | |||
end | end | ||
end | end | ||
Line 89: | Line 91: | ||
then | then | ||
-- Check if a translation of the pagename exists in English | -- Check if a translation of the pagename exists in English | ||
local newtitle = mw.title.new(title.prefixedText .. '/' .. 'en') -- Costly | local newtitle = mw.title.new(title.prefixedText .. '/' .. 'en', namespace) -- Costly | ||
-- Use the translation when it exists | -- Use the translation when it exists | ||
if (newtitle.id ~= 0) | if (newtitle.id ~= 0) | ||
Line 97: | Line 99: | ||
else | else | ||
-- Check if a translation of the pagename exists in that language | -- Check if a translation of the pagename exists in that language | ||
local newtitle = mw.title.new(title.prefixedText .. '/' .. subpage) -- Costly | local newtitle = mw.title.new(title.prefixedText .. '/' .. subpage, namespace) -- Costly | ||
if (newtitle.id == 0) | if (newtitle.id == 0) | ||
then | then | ||
-- Check if a translation of the pagename exists in English | -- Check if a translation of the pagename exists in English | ||
newtitle = mw.title.new(title.prefixedText .. '/' .. 'en') -- Costly | newtitle = mw.title.new(title.prefixedText .. '/' .. 'en', namespace) -- Costly | ||
end | end | ||
-- Use the translation when it exists | -- Use the translation when it exists |