1 admin_bar.module | admin_bar_locale_links() |
Build Locale links.
File
- core/
modules/ admin_bar/ admin_bar.module, line 498 - Render an administrative bar as a dropdown menu at the top of the window.
Code
function admin_bar_locale_links() {
if (!module_exists('locale') || !language_multilingual()) {
return array();
}
global $language;
$language_default = $language;
$path = backdrop_is_front_page() ? '<front>' : $_GET['q'];
$language_links = language_negotiation_get_switch_links(LANGUAGE_TYPE_INTERFACE, $path);
if (!isset($language_links->links)) {
return array();
}
foreach ($language_links->links as $language_link) {
if ($language_link['language']->langcode == $language_default->langcode) {
continue;
}
if (!empty($language_link['href'])) {
$links[$language_link['language']->langcode] = array(
'#attributes' => array('class' => array('locale')),
'#title' => isset($language_link['language']->native) ? $language_link['language']->native : $language_link['language']->name,
'#href' => url($language_link['href'], array(
'language' => $language_link['language'],
'absolute' => TRUE,
)),
'#below' => array(),
'#original_link' => array(),
);
}
else {
$links[$language_link['language']->langcode] = array(
'#attributes' => array('class' => array('locale')),
'#title' => isset($language_link['language']->native) ? $language_link['language']->native : $language_link['language']->name,
'#type' => 'markup',
'#prefix' => '<span>',
'#markup' => (isset($language_link['language']->native) ? $language_link['language']->native : $language_link['language']->name) . ' (' . t('unavailable') . ')',
'#suffix' => '</span>',
);
}
}
return $links;
}