providing the family of Awards

Telephone: +44 (0)1827 305940
Facsimile: +44 (0)1827 305941

You are here

Menus and languages in Drupal 6


I have been updating the menu links for the different languages that the INGOT learning site supports. Some things are far from intuitive! So I decided to document what I found here. 

On this site the Primary links are across the top of the page

Home - Certificates - Users - etc

These are the main menu links additional to user account details in the upper right hand block.

​The language switching block is to the lower right. The plan is that the basic primary links menu structure is common across languages so when a country flag is clicked in the language switching block, the primary links will be translated to the new language domain and the links from those menu entries will go to the relevant translated language page. Partners can then translate and localise these pages and further links from them to the degree that they want to. The only exception is the EUprojects menu link as this is for administrative purposes and will only ever be needed in English.

How I thought it should work

In the image above, from the menu administration in Drupal, the dialogue enables various attributes for the menu entry to be specified. This particular entry "Users" is a top level menu item in the primary links menu bar so it does not lead to any specific page, only to sub-menus which in turn link to pages. In this case clicking the menu entry will just return you to the home page hence <front> in the top path field. It means clicking the menu item will take the user to <front>. The name displayed in the menu is specified in the menu title link and in the lowest field "All languages" is set for the specified language. The idea is that if you have translated the Menu title in the language translation interface in the administration section, when you switch language blocks, the menu item will display in the correct language and the path field will take you to the home page for that language using the <front> link. You can search for (in this case) "Users" using the translate interface, clicking the menu option to only return where the word Users is employed in menus. Then fill in the available language fields with the word for "Users" in each language in the translate interface dialogue and save.  
So does it work? Well yes in this particular case it does. However, I found that if the menu item is pointing at pages other than <front>, the menu entries don't display at all on switching languages. This is complicated by the fact that menu options won't show if they lead to a page for which you have no access rights. Eg if you are not logged in you lose things that require you to be logged in. That is reasonably logical because the system doesn't know if you can use that page until you log in. So when checking remember that could be the reason something isn't showing rather than something isn't working. Another case where it works differently is if the link from the menu is to one of the content types that can be translated directly from the source page. 

How to link translatable pages

In order to get menus linked to translatable pages (content types) to display in each language it is necessary to specify the specific language that the menu is intended to display and link to rather than leaving it set to all languages. Of course this is rather less elegant since we now have to create multiple versions of the menu item instead of just one that has "all languages" set. The good news is that the menu item can be generated automatically at the time a new translation of the original source page is created. 
To do this go to edit for the English source page for the translation, click on translate and add translation for the language. At the top there is the page title and below that the menu option details. Put in a translation for the page title (eg just use Google translate to start with, that can be changed later by your translator but it helps identify this as a page translated into the target language). Now put in the Menu link title as it will appear in the menu tree. The parent item is the menu option from which this will become a sub-menu leaf. Now scroll to the bottom and save.
Saving this translate page will automatically create a menu item in the menu admin space. You can go to admin and menus and organise and edit these from there. The main problem is that with a site like ours currently with 16 languages there are a lot of them. 
All quite simple really but it took quite a bit of time to figure out that the "all languages" option only works for menu links not leading to translatable pages. Indeed you have to use the "all languages method for menu items linking to eg "Create content" because the "Create content" page is not translatable by the usual method of clicking a translation tab. 
So in summary, if the Menu links to a page that is translate using the source page and then edit and a translate tab you generate individual primary links menu items direct from the page when it is published as a translation. If the menu is not linking to that type of page use the All languages setting in the menu items parameters and use the translate interface to generate the language translations for that menu item.