7

I need to show a breadcrumb on my client website but it is required to be in two languages I have tried several approaches and modules but all of it show the breadcrumb in one language only.

Please, If anyone have an idea about this I appreciate your help.

Besides, Could you please explain more about using default drupal breadcrumb what should I have been installed to use breadcrumb correctly? Do I need breadcrumb + another module ???

Regards,

5
  • You need to give details about where you are placing the breadcrumb and how you are translating your site. That said, this answer may be of use: drupal.stackexchange.com/questions/59930/… Commented Feb 17, 2013 at 9:27
  • Thanks Patrick, I am using taxonomy to categorize my content with localized vocabulary, and I am using the default taxonomy term view to display categorized content. I have installed easy breadcrumb but is display the breadcrumb only in English.
    – copoet
    Commented Feb 17, 2013 at 9:42
  • Most breadcrumb modules on drupal.org do not have multilingual capability. Unless a module specifically lists itself as having support, I would assume that there is no support. Commented Feb 17, 2013 at 10:41
  • 1
    Crumbs has some level of multilingual capability (we are using it with translated menu links, not sure about vocabularies). I would try that one first, create an issue for missing stuff Commented Apr 5, 2013 at 12:56
  • +1 to Crumbs. So far the only thing to really work "out of the box" to get translated breadcrumbs. It also seems to be the best module to provide a structured approach to coding separate breadcrumb recipes. Commented Nov 24, 2014 at 21:01

5 Answers 5

1

Assuming you want your breadcrumbs like this:

  Home/La Casa >> Node/Nodo >> Friends/Amigos

You could override template_preprocess_breadcrumb like so:

  function MY_THEME_preprocess_breadcrumb(&$variables)
  {
     $breadcrumbs = &$variables['breadcrumb'];
     foreach($breadcrumbs as &$breadcrumb)
     {
         $breadcrumb .= '/' . locale($breadcrumb, null, 'SP');
     }
   }

Don't quote me on the langcodes, and this would require that you have the locale module installed and enabled, but it should output the above example breadcrumb.

1

I used Custom Breadcrumbs Module it has the ability to add breadcrumb for each language... For breadcrumbs which are automatically generated translation can be done in String Translation Table. I think multilingual breadcrumb can also be created using Path Breadcrumbs

0

Drupal has some mainstream contributed modules that can handle this in most cases. Using built-in interface translation and i18n_string, you can add translations for many of the main breadcrumbs in Configuration -> Regional & Language -> Translate Interface -> Translate.

Several modules can help you get these strings to begin with. You can use the potx module to pull all built-in interface strings from your other installed modules, which puts the strings into the locales_source table. Then you can use the l10n_update module to search for community-contributed translations for these strings.

For the last part of a breadcrumb that comes from a node, for example, Drupal will display the translated title of the node if it finds it. For Content Translation (node-based), the node displays its title in the breadcrumb, and for Entity Translation (field-based), you can enable the title module to convert the title property to a field, which can then be translated and displayed in the breadcrumb.

0

Hope this helps:

<?php
    //breadcrumb fix
        function THEME_NAME_menu_breadcrumb_alter(&$active_trail, $item) {
            global $language ;
            $lang_name = $language->language;
            $i = 0;
            foreach (array_keys($active_trail) as $key) {
                if($i!=0){
                    $translatedValue = i18n_string_translate(array('menu', 'item', $active_trail[$key]['mlid'], 'title'), $active_trail[$key]['title'], array('langcode' => $lang_name, 'sanitize' => FALSE));
                    $active_trail[$key]['title'] = $translatedValue;
                }
               $i++;
            }
        } 
    ?>
0

Assuming you are using the i18n module, including submodule i18n_menu, then the most reliable way of translating your breadcrumbs would be implementing hook_menu_breadcrumb_alter and run _i18n_menu_link_title function on each item.

This should work:

/**
 *   Implements hook_menu_breadcrumb_alter()
 */
function YOURMODULE_menu_breadcrumb_alter(&$active_trail, $item) {
  foreach ($active_trail as $index => $breadcrumb_item) {
    if (isset($breadcrumb_item['mlid'])) {
      $active_trail[$index]['title'] = _i18n_menu_link_title($breadcrumb_item);
    }
  }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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