1 locale.module locale_block_view($type)

Implements hook_block_view().

Displays a language switcher. Only show if we have at least two languages.

File

core/modules/locale/locale.module, line 848
Add language handling functionality and enables the translation of the user interface to languages other than English.

Code

function locale_block_view($type) {
  if (language_multilingual()) {
    $path = backdrop_is_front_page() ? '<front>' : $_GET['q'];
    $links = language_negotiation_get_switch_links($type, $path);

    if (isset($links->links)) {
      backdrop_add_css(backdrop_get_path('module', 'locale') . '/css/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;
    }
  }
}