Add lang and hreflang attributes to the language links of the login page.
authorDerk-Jan Hartman <hartman@videolan.org>
Sun, 29 Jul 2012 14:06:37 +0000 (16:06 +0200)
committerAlexandre Emsenhuber <ialex.wiki@gmail.com>
Sun, 19 Aug 2012 09:48:11 +0000 (11:48 +0200)
- 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
includes/specials/SpecialUserlogin.php

index 2dea396..5b4580c 100644 (file)
@@ -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.
index f0b15db..19af852 100644 (file)
@@ -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
                );
        }
 }