Dear lazyweb,

I'm currently setting up a drupal-based site. While it's working pretty well and has allowed me to get most things done that I needed doing, there's one remaining issue that would need resolving. I tried asking for suggestions on the drupal support mailniglist and on the #drupal-support channel on freenode, but I haven't received a solution thus far. Hopefully someone reading one of the planets I'm on knows the answer.

The site would need to be multilingual. That is to say, not just the interface, but also all static content and some of the nonstatic content would need to be translated in two (at first) languages (perhaps more will follow in the future).

Using the i18n drupal module, I have been able to create alternate-language versions of some nodes, and enable a language chooser, allowing a visitor to choose a different content language for the site and seeing the site translated. However, there is one issue that needs to be resolved: the menu.

The i18n.module does not create an alternate version of a translated node; rather, it creates a new node. This node then is linked to the original node by way of some extra table that the i18n.module installs. As such, both versions of the same content will have a different node number. To give a concrete example, the Dutch version of the "about" page on the site I'm creating is node/2, whereas the English version is node/10. Since you might want to review the English version of a node even if you request the site in Dutch, you do not unexpectedly get the Dutch version anyway if you request node/10.

Since the node number is part of the URL of the node, this makes it impossible to create a link to "the about node, in whatever language is appropriate".

The i18n module also comes with a "i18nmenu" module, which allows one to translate a menu item's description using gettext. This works, but it has one fatal flaw: it does not allow to change the target of the link. As a result, and given the above, it's impossible to create a menu item for "the about node in the current language, whatever that means".

In an effort trying to work around that issue, I've come up with a number of things. Unfortunately, none of them seem to work to satisfaction.

  • Create a URL alias, including the language prefix that gets added by the i18n module, and then link to the version without that language prefix from the menu: suggested by the i18n module's documentation, this does work, but has the problem that the menu system then doesn't detect that you're viewing the content which the menu has linked to. As a result, child menu entries don't get expanded, which I would need (my menu would get too convoluted if everything would be visible from the onset).
  • Create a custom_url_rewrite function to change the target of the URL alias depending on the value of the $locale variable (which contains the current interface language). Turns out that this breaks the language prefix (i18n.module installs its own custom_url_rewrite function). Efforts to change my function or the i18n version of that function to change in such a way that both translations are done have failed; they seem to confuse drupal in some way. This is possibly due to the fact that the custom_url_rewrite function in i18n.module only performs one end of the translation, while my needs require both ends; I don't know enough about drupal to figure out how i18n's other side is implemented.
  • Create something which will actually search for articles, in such a way that it is guaranteed that it will only return one article (e.g., by using a special taxonomy term or some such), and link to that search from the menu. This works, but only returns the teaser version of the page, requiring users to click a "read more"-type of link, which is not what you'd expect from a menu system. Ensuring that nodes to which we'll link from the menu are created so that they don't have a teaser isn't desirable, either.

At this point, I'm effectively out of ideas. If anyone has a solution (or can tell me why it isn't possible), I'll gladly hear it, either as a comment on my blog or by mail on w@uter.be.