Hi! Both Corporate Clean and Blue Masters do not have support for multilingual main menu.
If a site has i18n and menu translation modules installed and there are translation pairs for each menu item normally you'd want only items of the currently selected language to appear on the menu — right now my favorite theme shows all of them at once (which is not the case for Bartik and Seven).
I tried to replace the code in page.tpl.php and it worked but the menu looked ugly and I don't know how to fix it.
It would be great if I manage to make it look exactly like original but since I'm not very much of a hacker I'd appreciate if someone could also take a look into it.

Oleg

Comments

Looks like it is a common problem for custom themes in D7.
See http://drupal.org/node/1021462

I got the same problem and found the solution.
The menu is not localized because in "page.tpl.php" template, the function "menu_tree" is being used to build the menu instead of "i18n_menu_translated_tree" (assuming you are using i18n module for translations).

In the "page.tpl.php" of your theme you should have:

<div id="header-menu-inside">
    <?php
    $main_menu_tree
= i18n_menu_translated_tree(variable_get('menu_main_links_source', 'main-menu'));
    print
drupal_render($main_menu_tree);
   
?>

</div><!-- EOF: #header-menu-inside -->

tugis, that's really great!
thanks for sharing and Happy New Year!

Hi, the suggestion in #2 works and it would be great if it could be great if it could be added, although I guess that a check should be made first to check whether i18n is installed. Thanks!

Assigned:Unassigned» gtsopour

Thank you everyone

I will checkout directly your proposals and i will commit them

Thanks
/George

Hi all,

I can confirm that #2 is also working!

Sorry for the off topic but has anyone found a nice an clean way of implementing the language switcher on the theme?

BR,
Su_root

EDIT: I don't even know where to start editing the layout of the language switcher so a point in the right direction is appreciated.

Hi all,

I also confirm that #2 is working fine.

Just what I was looking for.

Best Regards,
Chris

Hello,
Thank you sincerely for your help and for your comments in this issue.
Could you please review the following code once again before committing it?

<div id="header-menu-inside">
      <?php
   
if (module_exists('i18n')) {
   
$main_menu_tree = i18n_menu_translated_tree(variable_get('menu_main_links_source', 'main-menu'));
    } else {
   
$main_menu_tree = menu_tree(variable_get('menu_main_links_source', 'main-menu'));
    }
    print
drupal_render($main_menu_tree);
   
?>

</div><!-- EOF: #header-menu-inside -->

Thanks
/George

Status:Active» Closed (fixed)

Thank you, I can confirm that this code works for both of my 2 sites one of which has no i18n module. The other one now shows menu items from one language only - just what I was looking for.

Thank you all for your help.

Version:7.x-1.0» 7.x-1.3
Status:Closed (fixed)» Reviewed & tested by the community

#8 works! Thanks!

Status:Reviewed & tested by the community» Fixed

Committed and will be included into next Corporate Clean release 7.x-1.4

Thanks
/George

Version:7.x-1.3» 7.x-1.4
Category:feature» bug
Priority:Minor» Critical
Status:Fixed» Needs work

Call to undefined i18n_menu_translated_tree

I don't have i18n_menu enabled, causing this error, you need to change the condition from i18n to i18n_menu in http://drupalcode.org/project/corporateclean.git/blobdiff/8bc183cf3ed834...

if (module_exists('i18n_menu')) {

Hello SebCorbin

Thank you sincerely for your help and for your report in this issue.
I will change this code with your suggestion and come back with the final code before commiting for testing.

Thanks
/George

Not work for my site! Please help! version 1.4 i18n was updated.

Fatal error: Call to undefined function i18n_menu_translated_tree() in /home/virtwww/w_raresoft_913db49d/http/sites/all/themes/corporateclean/page.tpl.php on line 39

<div id="header-menu-inside">
    <?php
   
if (module_exists('i18n')) {
   
$main_menu_tree = i18n_menu_translated_tree(variable_get('menu_main_links_source', 'main-menu'));
    } else {
   
$main_menu_tree = menu_tree(variable_get('menu_main_links_source', 'main-menu'));
    }
    print
drupal_render($main_menu_tree);
   
?>

</div><!-- EOF: #header-menu-inside -->

@su_root have you tried https://drupal.org/project/lang_dropdown ?

Hello cheiwe,
as SebCorbin said, please try the following code.

<?php
   
if (module_exists('i18n_menu')) {
   
$main_menu_tree = i18n_menu_translated_tree(variable_get('menu_main_links_source', 'main-menu'));
    } else {
   
$main_menu_tree = menu_tree(variable_get('menu_main_links_source', 'main-menu'));
    }
    print
drupal_render($main_menu_tree);
   
?>

Thanks
/George

Status:Needs work» Fixed

Hello,

Just committed the code from comment #16

Τhank you all sincerely for your comments
/George

Automatically closed -- issue fixed for 2 weeks with no activity.