-
-
Save iryston/16d93bc9115ad23a719bcd06f9c6af93 to your computer and use it in GitHub Desktop.
Implements hook_language_switch_links_alter() - Alter language switch links.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Implements hook_language_switch_links_alter(). | |
*/ | |
function mymodule_language_switch_links_alter(array &$links, $type, $path) { | |
global $language; | |
if ($type == LANGUAGE_TYPE_INTERFACE && isset($links[$language->language])) { | |
foreach ($links as $langcode => &$link) { | |
// If no translation exists, redirect to frontpage | |
if (empty($link['href'])) { | |
$link['href'] = '<front>'; | |
} | |
// Change default link title | |
$link['attributes']['title'] = t( | |
"View this page in !language", | |
array('!language' => $link['language']->name), | |
array('langcode' => $link['language']->language) | |
); | |
$link['title'] = substr($link['language']->native, 0, 2); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment