Module:Redirect-distinguish: Difference between revisions

Undid revision 747302044 by Nihiltres (talk) revert pronoun detection - this actually causes problems when it comes to misspellings of words that need distinguishing
(Undid revision 752883540 by Steel1943 (talk) to further explain)
(Undid revision 747302044 by Nihiltres (talk) revert pronoun detection - this actually causes problems when it comes to misspellings of words that need distinguishing)
Line 12:
 
function p._redirectDistinguish(args)
--Check for first argument, and evaluate redirect if present
if not args[1] then
return mHatnote.makeWikitextError(
Line 28 ⟶ 27:
args[1] = args[1] .. '[[Category:Missing redirects]]'
end
--Check for second argument
if not args[2] then
return mHatnote.makeWikitextError(
Line 37 ⟶ 34:
)
end
 
--Get pronoun from Wikidata. Really basic, but it should work.
local pronouns = {
['female'] = 'She is',
['transgender female'] = "She is",
['male'] = 'He is',
['transgender male'] = 'He is',
['default'] = 'They are'
}
local wde = mw.wikibase.getEntity()
local p31 = (wde and wde:formatPropertyValues('P31').value) == 'human'
local p21 = wde and wde:formatPropertyValues('P21').value
local pronoun = p31 and (pronouns[p21] or pronouns['default']) or 'It is'
 
--Assemble hatnote and return
args = mTableTools.compressSparseArray(args)
--Assignment by removal here makes for convenient concatenation later
local redirect = table.remove(args, 1)
local text = string.format(
'"%s" redirects here. %sIt is not to be confused with %s.',
redirect,
pronoun,
mHatlist.orList(args, true)
)
Anonymous user