function locale_block_view

Implements hook_block_view().

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

File

modules/locale/locale.module, line 1040

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;
        }
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.