From 0d70409b5e0e84e237f881dbc88f0ad207664b27 Mon Sep 17 00:00:00 2001 From: Derk-Jan Hartman Date: Sun, 29 Jul 2012 16:06:37 +0200 Subject: [PATCH] Add lang and hreflang attributes to the language links of the login page. - Adding these attribues should make them easier to interpret for VoiceOver and other assitive technologies. - This assumes that people will enter the name of the language in the target language to MediaWiki:loginlanguagelinks, which is a convention but not a requirement of course. However I think making the bet that people actually do that is safe enough. - Switch the name of the old attr variable to query, which better reflects what it is supposed to be used for. Change-Id: I0cdae9f1e539b9b9c2b99ea1db1ba62bbbb0bdc5 --- RELEASE-NOTES-1.20 | 1 + includes/specials/SpecialUserlogin.php | 17 +++++++++++------ 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/RELEASE-NOTES-1.20 b/RELEASE-NOTES-1.20 index 2dea396f44..5b4580ca3a 100644 --- a/RELEASE-NOTES-1.20 +++ b/RELEASE-NOTES-1.20 @@ -125,6 +125,7 @@ upgrade PHP if you have not done so prior to upgrading MediaWiki. * jsMessage: Redesigned in Vector/Monobook as floating bubble with auto-hide. * New hook 'ParserTestGlobals' allows to set globals before running parser tests. * Allow importing pages as subpage. +* Add lang and hreflang attributes to language links on Login page. === Bug fixes in 1.20 === * (bug 30245) Use the correct way to construct a log page title. diff --git a/includes/specials/SpecialUserlogin.php b/includes/specials/SpecialUserlogin.php index f0b15db25a..19af85245e 100644 --- a/includes/specials/SpecialUserlogin.php +++ b/includes/specials/SpecialUserlogin.php @@ -1269,19 +1269,24 @@ class LoginForm extends SpecialPage { // no link for currently used language return htmlspecialchars( $text ); } - $attr = array( 'uselang' => $lang ); + $query = array( 'uselang' => $lang ); if( $this->mType == 'signup' ) { - $attr['type'] = 'signup'; + $query['type'] = 'signup'; } if( $this->mReturnTo !== '' ) { - $attr['returnto'] = $this->mReturnTo; - $attr['returntoquery'] = $this->mReturnToQuery; + $query['returnto'] = $this->mReturnTo; + $query['returntoquery'] = $this->mReturnToQuery; } + + $attr = array(); + $targetLanguage = Language::factory( $lang ); + $attr['lang'] = $attr['hreflang'] = $targetLanguage->getHtmlCode(); + return Linker::linkKnown( $this->getTitle(), htmlspecialchars( $text ), - array(), - $attr + $attr, + $query ); } } -- 2.20.1