In the locale.module file there is:

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;

I would like to alter this function in my custom module. I've created a custom module named custom (module is enabled). I've tried to alter the function with this function : hook_block_view.

But when I do that it doesn't work:

function other_block_view($delta = '')

Nothing happens ... . The module works because hook_block_view_alter works. But I need to change the $links variable in that other function .. .


I've fixed it like this:

function theme_links__locale_block(&$variables) {
    $links = array();

    foreach($variables['links'] as $link)
        $link['title'] = $link['language']->language;
        $links[] = $link;

    $variables['links'] = $links;

    $content = theme_links($variables);
    return $content;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.