function locale_block_view in Drupal 7
Implements hook_block_view().
Displays a language switcher. Only show if we have at least two languages.
File
- modules/
locale/ locale.module, line 1038 - Add language handling functionality and enables the translation of the user interface to languages other than English.
Code
function locale_block_view($type) {
if (drupal_multilingual()) {
$path = drupal_is_front_page() ? '<front>' : $_GET['q'];
$links = language_negotiation_get_switch_links($type, $path);
if (isset($links->links)) {
drupal_add_css(drupal_get_path('module', 'locale') . '/locale.css');
$class = "language-switcher-{$links->provider}";
$variables = array(
'links' => $links->links,
'attributes' => array(
'class' => array(
$class,
),
),
);
$block['content'] = theme('links__locale_block', $variables);
$block['subject'] = t('Languages');
return $block;
}
}
}