Hi,

I'm not sure if i messed up something or if this is standard behaviour.
I have a quite fresh install of drupal 4.7 and latest i18n cvs (15th of may).

With my 4.6 install with i18n, i used to be able to translate the text of a menu item through the locale module.
On the latest version i can't anymore...The locale module doesn't find the menu item string...

Also the link where the menu item refers to, doesn't get translated to the proper language, even though the Translation block links do. E.g. 'en/about' should become 'nl/over' when i click the dutch flag, but it becomes 'nl/about' instead.
It used to work like i want on the 4.6 version, but i applied some patches made my New Oceans to get it like that...

I though the i18n_menu module used to take care of all of this, but now this seems integrated with the other modules.
Maybe something's missing?

Comments

Marc Bijl’s picture

With a fresh install of i18n (without all "patches" I've used before in 4.6.6), the translation of menu items using locale module is not any kind of problem for me...

However, it's not possible yet to let a menu item point to the right node, depending on the language. This is assumed to be done by the menu module, which is on it's way:
- http://drupal.org/node/62822

The translation block has been fixed last weekend, so that should be fine too:
- http://drupal.org/node/62799

Resume:
- Menu translation: should be ok
- Menu functionality: on it's way
- Translation block: should be ok

jose reyero’s picture

I've added the i18nmenu.module which seems to work without any update :-)

About the menu items linking to the right nodes, try these url aliases:

en/mynode -> node/1
es/mynode -> node/2

Marc Bijl’s picture

Hmm. Don't get it...

To explain, I have defined these nodes:

  • idea
    (node id 1, english, url alias idea)
  • idee
    (node id 2, dutch, url alias idee)
  • contact
    (node id 17, english, url alias en-US/idea)
  • contact
    (node id 18, dutch, url alias nl/contact)

I have also defined these English primary links in the menu system:

  • idea
    (menu id 84, path node/1)
  • contact
    (menu id 69, path node/17)

To get these menu items translated, I have used localization:

  • idea > idea (en-US) and idee (nl)
  • contact > contact (en-US) and contact (nl)

So: when I'm browsing the English site (prefix en-US in address bar), all is fine. However, when I start browsing the Dutch site (prefix nl in address bar), the menu items are Dutch indeed, but they all point to the English nodes... Because I have nowhere assigned the primary links to a second node, namely the Dutch tranlated one.

Where and how should I define that one primary link can point to either an English node, or a Dutch node, depending on the language?

Marc Bijl’s picture

Moreover, browsing the site in English (language prefix en-US in address bar)...

... menu item / primary link idea points to example.com/en-US/idea (prefix ok, node ok)
... menu item / primary link contact points to example.com/en-US/contact (prefix ok, node ok)

But, browsing the site in Dutch (language prefix nl in address bar)...

... menu item / primary link idee points to example.com/nl/idea (prefix ok, node not ok)
... menu item / primary link contact points to example.com/en-US/contact (prefix not ok, node not ok)

A bit of inconsequent behaviour; probably I'm doing something wrong, but haven't found out what...

Hope this all makes a bit sense; if you're interested in my workflow in 4.6.6, just let me know.

Marc Bijl’s picture

What is table i18n_variable for? It's empty here... Can that be something wrong?

jose reyero’s picture

The table i18n_variable is for language dependent variables

Have you updated your settings file according to the new INSTALL.txt instructions?

$conf['i18n_variables'] =...
Marc Bijl’s picture

Hi Jose,

Yes, I have updated the settings file: /sites/default/settings.php ;-)

Hmm... You know what, this is how I used to administer primary links in 4.6.6; may be it makes clear how I'm thinking and what way(s) I'm trying to achieve the same in 4.7

Created nodes

  • Created node, e.g. 1, title "idea", url alias "idea" and assigned language en-US
  • Created node, e.g. 2, title "idee", url alias "idee" and assigned language nl
  • Created node, e.g. 17, title "contact", url alias "en-US/idea" and assigned language en-US
  • Created node, e.g. 18, title "contact", url alias "nl/contact" and assigned language nl

Created a hierarchical menu

  • Created one complete hierarchical menu in the menu system for the whole site in English (not in Dutch), including top level menu items "idea" (assigned path "#") and "contact" (assigned path "#")

Created primary links

  • For menu item "idea"/"idee":
    • First, administered the theme settings in the English administration:
      /en-US/admin/themes/settings/
      .
      Here the English primary links showed up, so here I defined English link texts, English urls and English descriptions: "idea", "idea" and "the idea of this site"
    • Second, administered the theme settings the in Dutch administration:
      /nl/admin/themes/settings/
      .
      Here the Dutch primary links showed up, so here I defined Dutch link texts, Dutch urls and Dutch descriptions: "idee", "idee" and "het idee van deze site"
  • For menu item "contact"/"contact":
    • First, administered the theme settings in the English administration:
      /en-US/admin/themes/settings/
      .
      Here the English primary links showed up, so here I defined English link texts, English urls and English descriptions: "contact", "en-US/contact" and "get in touch"
    • Second, administered the theme settings the in Dutch administration:
      /nl/admin/themes/settings/
      .
      Here the Dutch primary links showed up, so here I defined Dutch link texts, Dutch urls and Dutch descriptions: "contact", "nl/contact" and "neem contact op"

Resume: as you can see, the theme setting page used to be the area where I defined primary links and I changed the language prefix in the address bar to switch between administration languages and so switch between administering English respectively Dutch primary links.

However: now that primary links are not part of theme settings anymore, I don't know where to go and tell Drupal/i18n that one primary link (e.g. "idea") can point to two pages (e.g. "idea" or "idee" depending on the interface language.

I know in the menu system it's possible to create both an English primary link (pointing to the url alias of the English node) and a Dutch primary link (pointing to the url alias of the Dutch node), but then I get these two primary links side by side in the menu :\

Another option at the node's editing page might be assigning menu items, but here happens the same: if I assign an English menu item at the English node's editing page, and assign a Dutch menu item at the Dutch node's editing page, then I get these two menu items side by side in the menu as well...

Hope this makes clear how I used to work in 4.6.6 and why I don't know where to go in 4.7

Cheers ;-)
Marc

Marc Bijl’s picture

About my 4.6.6 workflow: forgot to mention that -of course- I assigned node 1 and 2, as well as 17 and 18, as being translations of each other.

Marc Bijl’s picture

Hmm. Small, little step further...

$conf['i18n_variables'] =... as I managed to define a dutch footer in the dutch administration page, and an english one in the english administration page. They show up in the site correctly (:

However, this workflow (administering in two different languages, that is, with two different language prefixes in the address bar) does not work for primary links in the menu system...

Does anyone know: where do I have to make the difference between dutch and english primary links, including their own paths to their own nodes?

jorditr’s picture

Hi Marc.

It's easy to have the primary links (and secondary working). Just add to the settings.php page inside the directory site/defaults at the end of the page

/**
 * Variable overrides:
 *
 * To override specific entries in the 'variable' table for this site,
 * set them here. You usually don't need to use this feature. This is
 * useful in a configuration file for a vhost or directory, rather than
 * the default settings.php. Any configuration setting from the 'variable'
 * table can be given a new value.
 */
//$conf = array(
//  'site_name' => 'My Drupal site',
//  'anonymous' => 'Visitor'
//);

$i18n_variables = array(
'phptemplate_primary_links',
'phptemplate_primary_links_more',
'phptemplate_secondary_links',
'phptemplate_secondary_links_more',
'site_frontpage',
'site_footer',
);

That means that this time when you go to the page en/admin/settings those elements will be saved as "english" but when you go to the page nl/admin/settings (which will be visualitzed on dutch throgh the l10n module) all those fields will be saved properly. Hopefully the i18n.module translation routines will do the rest... That means that this page save it's own information on every language version as localized general config parameters.

Also consider that you see translated the variables of the config page that you add to the list on the settings.php page but not the others. Obviously you don't have to do nothing on your template page, just let it call primary and secondary links the usual way, you don't need to customize anything.

Marc Bijl’s picture

Thanks for the info Jordi, but I know about the principle of the i18n_variables as I managed to get things like footer and slogan translated: http://drupal.org/node/63691#comment-99452

BTW
I defined $conf['i18n_variables'] = array( ... ); instead of $i18n_variables = array( ... );

But now it's about primary links, and those are not at the settings page, but at the menu page....

I get them translated through localization, but I don't get them working. That is, a Dutch primary link must point to the Dutch node = Dutch url alias, whereas the English translation must point to the English node = English url alias (different!).

At the menu page I have one set primary links, defined in English (en-US). If I switch the administration's language to Dutch, change the primary link "idea" into "idee", change the url alias, and save the whole thing, the the English menu item is gone (even if I switch the language for the administration page back to English...).

The other way around I have the same problems.

So it seems like a primary link as menu item can only be saved in one language. This is confirmed in the database, as footer, slogan etc get their own two rows in table i18n_variable (on row for nl and one row for en-US), whereas I still didn't manage to get two rows created for menu items / primary links.

Another option I've been thinking about, is defining the menu through the menu settings at the node editing page, so I can define a Dutch menu item + url alias for a Dutch node, and an English menu item + url alias for an English node. But if I do that, I get two menu items defined in the primary link menu, and they show up next to each other in the menu at the site...

So I'm wondering: where do you define primary links / menu items in both languages, including their own url aliases, which are different?

Hope you can help, as this is driving me crazy :\

Cheers,
Marc

BTW
In 4.6.6 I used to define the primary links at the theme settings page. In 4.7.0 these primary links are gone, and became part of the menu system. Therefore I have the slightest feeling we're not talking about primary links anymore, but about menu items. So that may be these need their own i18n_variables?

jorditr’s picture

Wops, wops, wops, primary and secondary links are not definied on any menu area (I have no idea how you can have defined primary menu links on any menu area...) BUT on the theme config area! :-D
Something like http://www.yoursite.com/en/admin/themes/settings/your_active_theme page.

All the themes that use phptemplates (and for sanity I always use phptemplates for my themes) define primary and secondary links through a form: one column for the entry, the second for the link, on an area called "Engine-specific settings". How do you do that? Well, the happy point here (if you haven't notice) is that this page works the same way than the config one, the parameters are saved depending on your current active language just because you have registered the variable on the setting.php file. Does my explanation makes sense? If not don't hesitate to ask me again :-)

Marc Bijl’s picture

That sounds how it needs to be done in 4.6.6: the way how I used to do as described here:
- http://drupal.org/node/63691#comment-99219

However, since I'm running 4.7.0, the primary links at the theme settings pages are gone, and they moved to the menu system. The basic configuration pages here at Drupal say about that:

As of 4.7, primary and secondary links have been incorporated into the menu system. To have primary and secondary links in your theme, you make them menu items. A fresh Drupal 4.7 install comes with an empty menu called "Primary Links" that is set to be used to display both the primary and secondary links.

You can read some more information about that here:
- http://drupal.org/node/63601
- http://www.drupalecommerce.com/node/653

And there's an interesting webcast here:
- http://www.lullabot.com/videocast/drupal-4.7-menu-system

So, I would love if things were like in 4.6.6 (and like you just described), but here in my administration it doesn't look like in 4.6.6 anymore. At the the theme settings pages I see just these areas:
> Global settings
-- Toggle display
-- Display post information on
-- Logo image settings
-- Shortcut icon settings
> Theme specific settings
-- Toggle display
-- Logo image settings
-- Shortcut icon settings

And indeed, in 4.6.6 there was an area called "Engine-specific settings", but it's gone :\

Marc Bijl’s picture

Just watched the webcast at http://www.lullabot.com/videocast/drupal-4.7-menu-system It makes very clear what differences there are in defining primary links between 4.6 and 4.7

luigi12’s picture

Unfortunately I cannot reconstruct how I got there, but the whole i18n system screwed up at some point and stopped to work in a meaningful matter. I ended up in deleting all posts and cleaning up the database. I'll try to replicate the sistuation as far as possible. Just a heads up ...

jorditr’s picture

I have no updated to 4.7 so I have no idea. I'm having a very powerful system working on 4.6 with lots of small customization here and there. Uhmm, I don't know maybe I'll wait to upgrade until i18n goes core ;-)

svendecabooter’s picture

I got it working now...
Seems the latest cvs release comes with i18n_menu.module now, which wasn't there in the version i tested when reporting this issue.

Thanks for the help guys. The module is really getting neat.. Keep up the good work!

Marc Bijl’s picture

Title: Translation of menu items doesn't work » How to point translated menu items (i.e. primary links) to the right nodes?
Category: bug » support

Suggestion
-----------
After having contact with topic starter xeniox, I suggest to change:
- Category
- Title

Actually, I allready did ;-)

Reason
-------
It seems like translating menu items isn't the problem anymore; if I'm right, anyone who posted in this topic knows how to do it. Is that correct?

Okay then, next step.

The question now seems to be (at least for me): how to get menu items, especially primary links, working? That is, pointing to the right nodes?

In 4.6.6 it used to be done by defining primary links (including url aliases) in the theme settings page, while the admin was set to the concerning language. Then switch admin language, etc, etc.

However, in 4.7.0 the primary links cannot be defined seperately (for each language) anymore at the theme settings pages; instead they became part of the menu system.

So, does anyone know how to achieve that primary link 1 (language A) points to node 1 (language A), whereas the translated version of that primary link points to node 2 (language B)?

boriso’s picture

One temporary solution is to use multilingual blocks.

boriso’s picture

Ok, actually the multilingual blocks work fine with menus in general (you create one menu for each language), but indeed it is not capable of handling the primary links. Sorry if I was misleading.

/boris

Marc Bijl’s picture

Assigned: Unassigned » Marc Bijl

Issue solved. Will try and write some explanation later today.

Marc Bijl’s picture

Status: Active » Fixed

Here's a quick 'n short explanation about creating multi lingual primary links (will create some better documentation soon). In this example I will work with Custom English (code/prefix en-US) and custom Dutch (code/prefix nl).

  • Define and enable languages via localization (adminster > localization). So, one language with name English and code en-US (this will become the English language prefix in the address bar), and one language with name Dutch and code nl (this will become the Dutch language prefix in the address bar)
  • Install the complete i18n module pack (how it's intended to be done in Drupal 4.7: upload, enable, set access rights, and run update.php to create/alter the database)
  • Create a language dependent variable for primary menu, like explained in the i18n documentation. This means, make sure you got this code in /sites/default/settings.php
    $conf['i18n_variables'] = array(
    
    	... ,
    	... ,
    	etc ,
    
            'menu_primary_menu',
    	'menu_secondary_menu',
    
    	... ,
    	... ,
    	etc ,
    
        );
    
  • Create a node, e.g. an English one like "idea", and assign English as language at the node edit page (this node will e.g. be node/1 with url alias "idea")
  • Create a translated node, e.g. a Dutch one like "idee", and assign the Dutch language at the node edit page (this node will e.g. be node/2 with url alias "idee")
  • Create an English menu for primary links (administer > menus > add menu). However, since Drupal comes with an English menu for primary links allready, this menu does not need to be created.
  • Create a seperate Dutch menu for primary links (administer > menus > add menu). Let's call it "primaire links".
  • Create an English menu item, for the English node, in the English primary link menu ("Primary links"). This can be done in two ways.
    • The first option is: by editing the node. So, go to the edit page of English node 1 (administer > content > edit), open the menu settings area, and (A) define the menu item's name as "idea" and (B) define the parent item as "Primary links".
    • The second option is: by adding a menu item. So, go to the edit page of the menu (administer > menus), and add an item to the menu "Primary links. Define as title "idea", as path "idea" and as parent item "Primary links".
  • Create a Dutch menu item, for the Dutch node, in the Dutch primary link menu ("Primaire links"). This can be done in two ways.
    • The first option is: by editing the node. So, go to the edit page of Dutch node 2 (administer > content > edit), open the menu settings area, and (A) define the menu item's name as "idee" and (B) define the parent item as "Primaire links".
    • The second option is: by adding a menu item. So, go to the edit page of the menu (administer > menus), and add an item to the menu "Primaire links. Define as title "idee", as path "idee" and as parent item "Primaire links".
  • Now tell Drupal that the menu "Primary links" is the English menu for primary links. First, make sure your admin interface language is English, then second go to the settings page for the menus. This means the address bar should be: mysite.com/en-US/admin/settings/menu (check the language prefix!) Then set the dropdown menu containing primary links to "Primary links".
  • finally tell Drupal that the menu "Primaire links" is the Dutch menu for primary links. First, make sure your admin interface language is Dutch, then second go to the settings page for the menus. This means the address bar should be: mysite.com/nl/admin/settings/menu (check the language prefix!) Then set the dropdown menu containing primary links to "Primaire links".

That's basically it! Have been writing these instructions a bit in a hurry, but I think this all should do the trick.

3B’s picture

harder to explain rather than doing ...

many many many many many many many thanks you both!
ciao

3B’s picture

BTW ... i found very usefull to include

'menu_parent_items',

in the $conf['i18n_....

just my 0.02€

3B’s picture

BTW (2) ... i'm kludging arount to avoid primary links to appear on top ... in favour of a more preferred "block" menu ... now, still looking how to fix layout (setting leafs/collapsed and indent ...) if any idea pls post

actually i've build a php block with this code

$primary_links = menu_primary_links() ;
print_r($primary_links) ;
print "hello" ;

   print'<div id="primary">' ;
   print theme('links', $primary_links) ;
   print '</div>' ;
 

but i do not want "links" style ...

3B’s picture

sometime we (me) loose control and look too far from our noosepoint !!!

print menu_tree(variable_get('menu_primary_menu', 0)) ;

as PHP content of a block !!!
(amazing Drupal!!! thanks again!!!)

klance’s picture

It seems like and unbelievably major pain to have as many menus as you have languages. In fact, if you use the path "mypage" as your menu item's path, instead of "en/mypage" or "nl/mypage" i18n will prepend the locale automatically, making the links point to "en/mypage" and "nl/mypage" when you click on them. If you go into localization and translate your menu items' titles so that they appear in the correct language, they actually work! The titles change and the links change when you change the language. Except for one thing--they don't expand. For flat menus, this is as far as you need to go. For hierarchical ones, you'll have trouble. I hacked menu.inc and got submenus to expand (see http://drupal.org/node/65960) and they work perfectly with breadcrumbs, taxonomy_access, etc. The only thing I have left to fix is the fact that tabs don't appear on regular pages when you view them, but I am currently running one menu for all languages. I work with big menus, and when I can flip back and forth between translations of pages and forum postings, it just seems a bit clunky to have to surf through several menus every time I need to make a change to one link, and hope that they all continue to remain consistent over time. The key to getting this working is matching url aliases like "en/mypage" or "nl/mypage" with menu paths like "mypage" in the menu, without breaking other things. Check it out and let me know what you think.

mandclu’s picture

Prepending the URL aliases with the language does indeed seem to work. It is a pain that this is necessary, since I know some users of the system will forget to do this, however.

There is another issue this approach seems to have raised, however. Now, when I go into the translations tab, it doesn't link up the translation anymore, next to the language in question, it has the "create translation" link again. I even tried using the "select node" feature to re-link it, but it wouldn't take.

So this is an important fix, but it does have some problems.

mandclu’s picture

One more thing I've noticed now... If I'm looking at an English item, say:
en/about

The links in the language block will point to the translated version, such as:
hu/about

clicking on that only shows me the Hungarian version of the content if I have specified the URL alias for the translation as "hu/about", even though this has the issues cited in my previous post.

What I just noticed, however, is that the language block links no longer function properly. While I'm looking at "hu/about", they link to the node by number, no longer by the alias. So, I'll see something like:
en/node/74

And of course, if I click on that, I see the Hungarian content in the English framework, which is bad. Any idea how to get that working?

davemybes’s picture

Surge_martin, I have been struggling with the same problem for a while now. I finally figured out something. In the block list there are two language blocks. On is "Language switcher" and the other is "Tranlations". Use the language switcher only on the front page. Then use the translation block on all other pages, EXCEPT the front page. Now when I hover over the various languages on a page, the correct url's are shown eg. en/competition and fr/concours.

I hope this helps you and others.

mandclu’s picture

Thanks for sharing your experience, incrn8. On my site, however, the two blocks seem to work in an identical manner.

One difference I can see is that it had been my intent to use the same url alias for each language, such as:
en/about
hu/about
de/about

...and so on. Any thoughts on why this would seem to be a critical difference?

Bodo Maass’s picture

I wanted to use links in their proper language, such as
en/home
de/start

This is not possible with the release from 03/06/2006. However, I found this pending patch: http://drupal.org/node/67814, which solved this problem for me.

texas-bronius’s picture

surge_martin: you might glean some good info from this growing "i18n for dummies" thread in which we're consolidating tips on basic multilingual setup, i18n menus, and switching between languages. Probably this posting isn't really a bug fix issue, so the thread might facillitate discussion a little better..?
-cheers

asiafan’s picture

I made my primary link menu multilangual without making two of it...

I noticed that aliases or links without a language tag find their destination automatically like the forum link goes to en/forum and hu/forum according to what language I am in. So then I made a new menu item in primary links with a link "about" (no language tag). Then I made two aliases:
/node/35 = en/about (node 35 is my about page in english)
/node/36 = hu/about
And then it works. I dont have an alias for "about" but when using the link from the menu in any language it puts that tag in front of it so then it goes to the right node.
And of course I have primary links set to be language dependent in settings.php.

Other stuff like polls, forums, moviereviews and thing like that I didnt have to set, they change the content with the language by default (using the translation block, not the language-switcher).

asiafan’s picture

the only disadvantage of the method I explained is that aliases (the alias word after en/ ) have to be the same in both languages

ledelboy’s picture

Just a quick addition. I am working with a left navigation theme, and New Oceans' recipe didn't seem to work at all. I had a Primary Links menu for English and a Primarios for Spanish, but I could only see the English links.

I am probably in a dumb mood, 'cause it took me too long to realize that if your primary links work as blocks, yo've got to treat them as blocks. I configured the Primary Links to show only on en/* pages and Primarios to show only on es/* pages. Works like a charm. I just wish more drupallers were as detailed in their cookboks.

Well, maybe it doesn't, since switching languages on the fly keeps giving me inconsistent results. But I really don't care. The one thing I've learned after three multilingual sites, is that a link to the alternate language(s) that go(es) to the other language home page is less confusing for my users than giving them the chance to jump from language to language anywhere in the site.

Anonymous’s picture

Status: Fixed » Closed (fixed)