Skip to content

Commit cb20874

Browse files
committed
Add support for <link hreflang> as suggested by Joost de Valk <[email protected]>
1 parent 7ce285d commit cb20874

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

include/header.inc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ if ($config["cache"]) {
3131
}
3232
header("Last-Modified: " . $tsstring);
3333
}
34+
if (!isset($config["languages"])) {
35+
$config["languages"] = array();
36+
}
3437

3538
?>
3639
<!DOCTYPE html>
@@ -51,13 +54,18 @@ if ($config["cache"]) {
5154
<link rel="canonical" href="http://php.net/<?php echo $_SERVER['BASE_PAGE']?>">
5255
<?php if ($shortname): ?>
5356
<link rel="shorturl" href="<?php echo $shorturl ?>">
57+
<link rel="alternate" href="<?php echo $shorturl ?>" hreflang="x-default">
5458
<?php endif ?>
5559
<?php endif ?>
5660

5761
<?php foreach($config["meta-navigation"] as $rel => $page): ?>
5862
<link rel="<?php echo $rel ?>" href="<?php echo $MYSITE ?><?php echo $page ?>">
5963
<?php endforeach ?>
6064

65+
<?php foreach($config["languages"] as $code): ?>
66+
<link rel="alternate" href="<?php echo $MYSITE ?>/manual/<?php echo $code?>/<?php echo $config["thispage"] ?>" hreflang="<?php echo $code?>">
67+
<?php endforeach ?>
68+
6169
<?php foreach($CSS as $filename => $modified): ?>
6270
<link rel="stylesheet" type="text/css" href="<?php echo $MYSITE ?>cached.php?t=<?php echo $modified?>&amp;f=<?php echo $filename?>" media="screen">
6371
<?php endforeach ?>

include/shared-manual.inc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,7 @@ function manual_navigation_related(array $setup) {
368368
// including HTTP header information
369369
function manual_setup($setup) {
370370
global $PGI, $MYSITE, $USERNOTES;
371+
global $ACTIVE_ONLINE_LANGUAGES;
371372

372373
//TODO: get rid of this hack to get the related items into manual_footer
373374
global $__RELATED;
@@ -404,6 +405,7 @@ function manual_setup($setup) {
404405
$config = array(
405406
"current" => "docs",
406407
"breadcrumbs" => $breadcrumbs,
408+
"languages" => array_keys($ACTIVE_ONLINE_LANGUAGES),
407409
"meta-navigation" => array(
408410
"contents" => $base . $setup["home"][0],
409411
"index" => $base . $setup["up"][0],

0 commit comments

Comments
 (0)