A normal menu item has a language field attached to it. Can the same be done for a container?

Comments

rokr’s picture

+1
Container names should be translatable.
Nice module!

JohnAlbin’s picture

Hi Martinus and Ronald!

Containers are actually just standard menu links with these special traits:

  1. Containers have no URL path associated with them. So they are not links, just regular text.
  2. Containers are menu items that are always expanded. Since you can't go to the container’s "page", the only way to see its children links are for the container to be always expanded.
  3. The HTML wrapper around the container's title is controlled with theme_menu_item_container(). See the README.txt for more info.

To drupal's menu system containers and menu items are the same thing. So containers should be translatable just like menu items.

Are you having specific problems getting containers translated? (please tell me what.) Or are you just asking if they can be translated? (answer: I think so.)

JohnAlbin’s picture

Status: Active » Postponed (maintainer needs more info)
lolandese’s picture

Hi John,

A multilingual menu can be setup in multiple ways. I might use the "wrong" method to create my multilingual menus. I normally make a menu item in let's say English, "about us", and another one in German, "über uns". Done by assigning a language when creating a menu item. It seems the same method can't be used with a menu item container. The language field doesn't exist as with a normal menu item.

You write "containers should be translatable just like menu items". Menu items are wrapped up in the t() function to be translatable, if I'm not mistaken. That doesn't seem to be the case for containers. When I search the text I've put inside a container, "about us", through the translate interface (admin/build/translate/search), it says "No strings found for your search".

But even then, usualy the children (that are links) of a container point to different language versions (at least on a multilingual site they do). Then we need also seperate containers, but this makes them appear multiple times in the menu, because they show up on each language. So I would see "about us" next to "über uns".

I'm probably missing something or, like said before, simply use the "wrong" method to create my multilingual menus.
Thanks for your help.

JohnAlbin’s picture

Martinus, I assure you that its me who doesn't know how to setup multilingual menus. As I've never done it!

I think I need to experience this for myself. Can you point to a tutorial or docs that say what modules I need to use to recreate your multi-lingual menus? Then I can debug a working example. Thanks!

lolandese’s picture

Ok John,

Only making multilingual sites, I often forget that only 1 on 12 Drupal sites is multilingual. Most site builders never have to set it up. :)

Sit tight, here we go! There are more ways to create multilingual menus. I explain the most basic.

On a clean D6 install:

  • Download the modules Internationalization and Menu item container , drush dl i18n menu_item_container
  • Enable Menu translation (a submodule of Internationalization), admin/build/modules. Depends on: Internationalization, Menu, Block translation, String translation, Locale, Content translation
  • Add a language, admin/settings/language/add
  • Open the form to add a menu item, admin/build/menu-customize/primary-links/add
  • In a new browser window (for comparison), open the form to add a container, admin/build/menu-customize/primary-links/container-add
  • Look at the bottom of both forms for the menu item and the container.

You'll see on the container form that the language field is not there.

JohnAlbin’s picture

Status: Postponed (maintainer needs more info) » Active

Oh, crap. I think that's because its a different form (obviously). And i18n module is altering the original "add menu item" form.

Hmm… I can work around that. Thanks for the info!

JohnAlbin’s picture

Status: Active » Fixed

Ok. The module now re-uses the standard menu item edit form and just alters it for container-specific attributes.

That means any module that works by altering the standard menu item form will work automatically with containers as well. :-)

Fixed. http://drupal.org/cvs?commit=487394

lolandese’s picture

Tested in a multilanguage site. Works now as expected. Great enhancement. Thanks a lot. Good work.

JohnAlbin’s picture

Yay!

Status: Fixed » Closed (fixed)

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