fbpx
Welcome, Guest
Username: Password: Remember me

TOPIC: Main Menu - Multilanguage

Main Menu - Multilanguage 1 year 4 weeks ago #23835

  • immcom
  • immcom's Avatar
  • Offline
  • New Member
  • Posts: 6
  • Thank you received: 1
  • Karma: 0
Using IDs - may work fine but is very confusing.
Using your own code
$header_menu = strtolower('mainmenu-'.JFactory::getLanguage()->getTag());
for the language tag instead, it works perfectly and is much simpler.
So, on the files mentioned above need to change the line
$header_menu = $params->get('header_menu', 'mainmenu');
with
$header_menu = strtolower('mainmenu-'.JFactory::getLanguage()->getTag());
and on mobilemenu.php with
$header_mobile_menu = strtolower('mainmenu-'.JFactory::getLanguage()->getTag()); -if using the same main menu
The administrator has disabled public write access.
The following user(s) said Thank You: ozwest

Main Menu - Multilanguage 1 year 4 weeks ago #23838

  • ozwest
  • ozwest's Avatar
  • Offline
  • Premium Member
  • Posts: 92
  • Thank you received: 2
  • Karma: 1
Awesome if that just works so simply.

My question would be if that could be implemented as a standard into the template? What do you think Chandan?
The administrator has disabled public write access.

Main Menu - Multilanguage 7 months 2 days ago #28379

  • cbrace
  • cbrace's Avatar
  • Offline
  • New Member
  • Posts: 2
  • Karma: 0
Hi all,

I am building a multi-language site in Joomla 4 with the Astroid framework. I found this thread because I was trying to configure the main menu to switch languages.

If I understand correctly, there are two ways to do this:

1. Duplicate the template style for each language and assign the main menu for each specific specific language under Template Options --> Header

2. Hack the php as instructed above

Having multiple templates is doable but cumbersome. I'm willing to patch the code, but that creates long-term maintenance headaches. It would be really nice to have a more elegant solution! I hope the devs will consider this.

Thanks
Last Edit: 7 months 2 days ago by cbrace. Reason: layout
The administrator has disabled public write access.

Main Menu - Multilanguage 7 months 1 day ago #28397

  • immcom
  • immcom's Avatar
  • Offline
  • New Member
  • Posts: 6
  • Thank you received: 1
  • Karma: 0
Hello Cbrace,
Attention that there is not yet a stable relise of J4.

Duplicating the template for each language is not real. Imagine you have 10 or more languages ...

The solution I have proposed is the fastest, however there is another very simple way:
Using only the Joomla interface create Only One main menu and create the items for each language and assign the language to the item.
Eg.
home-en -> english
home-it -> italian
about-en ...
about-it
In Astroid simply assign Main menu.
Enjoy!
The administrator has disabled public write access.

Main Menu - Multilanguage 7 months 1 day ago #28417

  • cbrace
  • cbrace's Avatar
  • Offline
  • New Member
  • Posts: 2
  • Karma: 0
Thank you @Immcom! I'm well aware that v4 is still in Beta. So far so good.

The single monolithic menu makes sense. I gave it a try and did encounter one issue: it breaks the language switcher module. As far as I can see, it only displays a language when there is a default menu item for a given language. Since a menu can only have one default, this breaks it.

I suppose one workaround would be to create language switcher hard-coding the menu URLs in a custom HTML module and publishing that.

Not sure yet what the best approach for me would be. Open to suggestions...
The administrator has disabled public write access.

Main Menu - Multilanguage 6 months 2 weeks ago #28823

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Posts: 4489
  • Thank you received: 646
  • Karma: 115
cbrace wrote:
I suppose one workaround would be to create language switcher hard-coding the menu URLs in a custom HTML module and publishing that.

This is a viable option and I have done this before.
Thank You,
If you like our support and products, tweet us at joomdev and let the world know about it.
The administrator has disabled public write access.
Moderators: chandandeep
Time to create page: 0.392 seconds