Author: wegge
Description:
Add semantic information for language equivalents of the current page, as determined by interlanguage links, with hreflang links in the <head>. See https://www.mediawiki.org/wiki/Special:Code/MediaWiki/46059#c1385 and https://lists.wikimedia.org/pipermail/wikitech-l/2015-February/080661.html for more information on the syntax.
Cf. T6901 (attributes for interwikis, not the same semantic value); T54429 (language converter already tries to do this but has issues); T70490 (language info for machine translation services).
This patch adds xml:lang links, as described in
http://www.w3.org/TR/2004/WD-xhtml2-20040722/mod-meta.html#sec_20.5.2. to all
pages with interlanguage links. A diff against the current (2005-jan-30 09:00
UTC) CVS REL1_4 is attached. The results can be seen in the source for the two
pages http://playwiki.wegge.dk/MediaWiki and
http://wiki.wegge.dk/MediaWiki_customizations
Diff against current code:
- Programming/MediaWiki/REL1_4/includes/SkinTemplate.php 2005-01-30
09:21:07.976778061 +0100
+++ playwiki/includes/SkinTemplate.php 2005-01-30 09:42:07.552766175 +0100
@@ -328,7 +328,8 @@ class SkinTemplate extends Skin {
$nt = Title::newFromText( $l ); $language_urls[] = array('href' => $nt->getFullURL(), 'text' => ($wgContLang->getLanguageName( $nt->getInterwiki()) !=
''?$wgContLang->getLanguageName( $nt->getInterwiki()) : $l),
- 'class' => $wgContLang->isRTL() ? 'rtl' : 'ltr');
+ 'class' => $wgContLang->isRTL() ? 'rtl' : 'ltr',
+ 'language_code' => $nt->getInterwiki());
} if(count($language_urls)) { $tpl->setRef( 'language_urls', $language_urls);
diff -rup -xCVS Programming/MediaWiki/REL1_4/skins/MonoBook.php
playwiki/skins/MonoBook.php
- Programming/MediaWiki/REL1_4/skins/MonoBook.php 2005-01-22
22:45:48.000000000 +0100
+++ playwiki/skins/MonoBook.php 2005-01-30 09:51:16.091509526 +0100
@@ -60,7 +60,13 @@ class MonoBookTemplate extends QuickTemp
<?php if($this->data['usercss' ]) { ?><style type="text/css"><?php $this->html('usercss' ) ?></style><?php } ?> <?php if($this->data['userjs' ]) { ?><script type="text/javascript"
src="<?php $this->text('userjs' ) ?>"></script><?php } ?>
<?php if($this->data['userjsprev']) { ?><script
type="text/javascript"><?php $this->html('userjsprev') ?></script><?php } ?>
- </head>
+ <?php if( $this->data['language_urls'] )
{foreach($this->data['language_urls'] as $langlink) { ?>
+ <link title="<?php echo $langlink['text'] ?> version"
+ rel="alternate"
+ xml:lang="<?php echo $langlink['language_code'] ?>"
+ resource="<?php echo $langlink['href'] ?>" />
+ <?php } } ?>
+</head>
<body <?php if($this->data['body_ondblclick']) { ?>ondblclick="<?php
$this->text('body_ondblclick') ?>"<?php } ?>
<?php if($this->data['nsclass' ]) { ?>class="<?php
$this->text('nsclass') ?>"<?php } ?>>
<div id="globalWrapper">
Version: 1.4.x
Severity: enhancement
URL: http://www.w3.org/TR/2004/WD-xhtml2-20040722/mod-meta.html#sec_20.5.2.