位置:locale.module 定义方法: /** * Implements hook_block_info(). */ function locale_block_info() { include_once DRUPAL_ROOT . '/includes/language.inc'; $block = array(); $info = language_types_info(); foreach (language_types_configurable(FALSE) as $type) { $block[$type] = array( 'info' => t('Language switcher (@type)', array('@type' => $info[$type]['name'])), // Not worth caching. 'cache' => DRUPAL_NO_CACHE, ); } return $block; } /** * Implements hook_block_view(). * * Displays a language switcher. Only show if we have at least two languages. */ 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; } } } |