Last modified: 2011-09-20 09:19:09 UTC
{{gender:}} is a very useful function to make templates like userboxes and user-related messages be more expressive, especially in some non-English languages. In Spanish for instance, the expression "This user is a doctor" is gender dependant, so you *must* say "[Este usuario|Esta usuaria] es un doctor". Those templates are almost always transcluded into User or User talk pages, so automatic username detection (if gender parameter is left blank) would be a nice facilitation. Note that {{PAGENAME}} is not a good username detector because it doesn't work correctly in subpages and archived discussions, so a more complex construction like {{#titleparts:{{PAGENAME}}|1}} must be used, but it would be easier omit it instead: {{gender:|Este usuario|Esta usuaria}} es un doctor. Alternatively, a {{USERNAME}} variable would be a more general solution for username detection when used into user spaces. It could also be used in phrases like: Hi {{USERNAME}}! instead of Hi {{PAGENAME}}!
*** This bug has been marked as a duplicate of bug 27364 ***
Sorry. I realized that USERNAME is not a good name for the variable I'm requesting for. I better change it for {{PAGEOWNER}} or {{USERSPACENAME}}, ie the name of the user whose personal space includes the variable. Thus {{PAGEOWNER}} = {{#titleparts:{{PAGENAME}}|1}}
(In reply to comment #1) This is *not* a duplicate of bug 27364
You can always create a template named PAGEOWNER. I don't think there is a need for another magic word.
You're right. The PAGEOWNER idea is just an alternative, the main request is that the default username of {{gender:|male|female}} should be the owner of the page where the function is included.
In MediaWiki:xyzzy, {{GENDER:|male|female|unknown}} is already addressing the reader of a messae, i.e. the currently logged in user. I doubt that is is a good idea to alter this behavour for other namespaces, because it is possible (though hardly advisable) to transclude those message anywhere with {{:MediaWiki:xyzzy}} and {{:MediaWiki:xyzzy/zxx}} and with {{int:xyzzy}} and we were likely to create inconsistencies. Since contributions are possibly moved or copied around, my preference goes with something like {{GENDER:username|male|female|unknown}} with a verbatim user name for the cases this bug is about. That can be had with {{GENDER:{{subst:#titleparts:{{PAGENAME}}|1}}|male|female|unknown}} on user page, user talk pages, and their subpages, if I am not mistaken.
(In reply to comment #6) > In MediaWiki:xyzzy, {{GENDER:|male|female|unknown}} is already addressing > the reader of a messae, i.e. the currently logged in user. Are you sure? Can you link a MediaWiki-spacename page where {{gender:|}} with empty username is included? If it is, I doubt it would be the better default. Default options should correspond to the more frequently encountered situations. IMHO, gender function will bring much more utility (ie. more frequent usage) in user space pages messages and userboxes, where messages both from and to the page owner should be easily gender-customized.
(In reply to comment #2) > Sorry. I realized that USERNAME is not a good name for the variable I'm > requesting for. I better change it for {{PAGEOWNER}} or {{USERSPACENAME}}, ie > the name of the user whose personal space includes the variable. > > Thus {{PAGEOWNER}} = {{#titleparts:{{PAGENAME}}|1}} What about {{BASEPAGENAME}} ?
(In reply to comment #7) > Are you sure? He is correct. I wrote the feature that way.
(In reply to comment #8) > What about {{BASEPAGENAME}} ? {{BASEPAGENAME}} doesn't always return the username. See what happens in page "User:Example/Archive/2010" {{BASEPAGENAME}} → Example/Archive {{#titleparts:{{PAGENAME}}|1}} → Example Furthermore, {{PAGEOWNER}} should also check for the namespace to be User or User Talk, and if not, then should return nothing. (In reply to comment #9) > He is correct. I wrote the feature that way. Ok thanks. I would have done a test before posting here if I could, but I'm not a bureaucrat. Nevertheless I searched for such a case and could not find any.
While {{BASEPAGENAME}} doesn't work, {{#titleparts:}} does. See http://www.mediawiki.org/wiki/Help:Extension:ParserFunctions#.23titleparts And you can always wrap it in a nice template :)