Module:R from sort name: Difference between revisions

Content deleted Content added
if page doesn't exist, default to unambiguous instead of throwing error
fix
 
(2 intermediate revisions by the same user not shown)
Line 1:
local c = {
disambig_magic_word = '__DISAMBIG__',
template_ambiguous = 'R from sort name/ambiguous',
template_unambiguous = 'R from sort name/unambiguous',
template_ambiguous = 'R from sort name/ambiguous',
cat_unambiguous_from = 'Category:Redirects from sort names',
cat_unambiguous_to = 'Category:Redirects from sort names by article title',
cat_ambiguous_from = 'Category:Redirects from ambiguous sort names',
cat_ambiguous_to = 'Category:Redirects from ambiguous sort names by article title',
err_not_redirect = '[[Template:R from sort name]] error: page is not a redirect',
}
 
local remove_accents = require('Module:Latin')._removeaccents
 
local category = function(category, chr)
return '[[' .. category .. ', ' .. remove_accents(chr) .. ']]'
end
 
local p = {}
Line 11 ⟶ 21:
if title.exists then
if title.isRedirect then
char_from = mw.ustring.sub(title.fullText, 1, 1)
char_to = mw.ustring.sub(title.redirectTarget.fullText, 1, 1)
if mw.ustring.find(
frame:preprocess(
Line 19 ⟶ 31:
true
) then
return frame:expandTemplate{(
frame:expandTemplate{title = c.template_ambiguous} ..
category(c.cat_ambiguous_from, char_from) ..
}
category(c.cat_ambiguous_to, char_to)
})
else
return frame:expandTemplate{(
frame:expandTemplate{title = c.template_unambiguoustemplate_umambiguous} ..
category(c.cat_unambiguous_from, char_from) ..
}
category(c.cat_unambiguous_to, char_to)
})
end
else