Add lang and hreflang tags to the variants in the variant menu's. This fixes bug...
authorDerk-Jan Hartman <hartman@users.mediawiki.org>
Sun, 26 Feb 2012 16:52:37 +0000 (16:52 +0000)
committerDerk-Jan Hartman <hartman@users.mediawiki.org>
Sun, 26 Feb 2012 16:52:37 +0000 (16:52 +0000)
I have not added the rel 'alternate' links, because they are also present in the <head>

includes/SkinLegacy.php
includes/SkinTemplate.php
skins/Vector.php

index 03ae3a4..eb637d7 100644 (file)
@@ -250,7 +250,7 @@ class LegacyTemplate extends BaseTemplate {
                                }
                                $s = $wgLang->pipeList( array(
                                        $s,
-                                       '<a href="' . htmlspecialchars( $title->getLocalURL( 'variant=' . $code ) ) . '">' . htmlspecialchars( $varname ) . '</a>'
+                                       '<a href="' . htmlspecialchars( $title->getLocalURL( 'variant=' . $code ) ) . '" lang="' . $code . '" hreflang="' . $code .  '">' . htmlspecialchars( $varname ) . '</a>'
                                ) );
                        }
                }
index 1a933dd..68e595b 100644 (file)
@@ -1000,7 +1000,9 @@ class SkinTemplate extends Skin {
                                                $content_navigation['variants'][] = array(
                                                        'class' => ( $code == $preferred ) ? 'selected' : false,
                                                        'text' => $varname,
-                                                       'href' => $title->getLocalURL( array( 'variant' => $code ) )
+                                                       'href' => $title->getLocalURL( array( 'variant' => $code ) ),
+                                                       'lang' => $code,
+                                                       'hreflang' => $code
                                                );
                                        }
                                }
index 74b2fff..cee8c0e 100644 (file)
@@ -371,7 +371,7 @@ class VectorTemplate extends BaseTemplate {
        <div class="menu">
                <ul<?php $this->html( 'userlangattributes' ) ?>>
                        <?php foreach ( $this->data['variant_urls'] as $link ): ?>
-                               <li<?php echo $link['attributes'] ?>><a href="<?php echo htmlspecialchars( $link['href'] ) ?>" <?php echo $link['key'] ?>><?php echo htmlspecialchars( $link['text'] ) ?></a></li>
+                               <li<?php echo $link['attributes'] ?>><a href="<?php echo htmlspecialchars( $link['href'] ) ?>" lang="<?php echo htmlspecialchars( $link['lang'] ) ?>" hreflang="<?php echo htmlspecialchars( $link['hreflang'] ) ?>" <?php echo $link['key'] ?>><?php echo htmlspecialchars( $link['text'] ) ?></a></li>
                        <?php endforeach; ?>
                </ul>
        </div>