Translations (title) works fine, though url alias for the translation is not rendered correctly.

If I have an English page News which is on node/457 with url alias /news

There is a Swedish translation of that node at node/899 (Nyheter) with url alias /nyheter

In menus the menu is set to language neutral and the menu item to the English content

Now, on the English page everything is fine, the menu item shows as News and has a url to /news, problem comes with the translated item which shows correctly as Nyheter but the url shows as node/899 instead of the wanted /nyheter, which is bad for my SEO.

Patch attached to solve the problem, what it does it to lookup the correct translation url alias and populate the findings to the menu items href.

CommentFileSizeAuthor
i18n_menu.patch1.55 KBmorgande
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Jose Reyero’s picture

Category: bug » feature

This doesn't look consistent with the rest of the features in the module and also you loose the ability to really define a language neutral menu item (that may point to a page in other language, why not?).

I thought menu items for nodes had language locked down for it to be the same of the node (Unless the menu is not translatable I guess..)

So maybe what you want to do instead if you want full control over your menu items is just having a different menu for each language. (Btw, there's some issue around about creating menu items for a node translation set, I cannot find it now...)

Some people may want this feature, though, I understand that, but this is a good one for a new module, see http://drupal.org/project/i18n_contrib.

Jose Reyero’s picture

Title: Menu translations and url aliases » Translate node menu links (and url aliases) on the fly.

More descriptive title.

swafran’s picture

I have the same issue, this is a bug not a module/feature request.

Menu items that point to a translation get output with node URLs instead of aliases.

- The link should be output this way in the produced HTML: href="de/my_page"

- Instead we get: href="node/65"

This is clearly a bug. If we use aliases on a site, we never want users to see the node URLs. This works in single-language sites, and should also work in internationalized sites.

Countzero’s picture

Issue summary: View changes

I support swafran on this one : the aliased paths should be used in menus for translation.

Tried the patch but it doesn't seem to change anything.

Countzero’s picture

Still struggling tih this issue. I ended up modifying the patch to customize it to inconditionally translate one of my menus? I _i18n_menu_link_localize :

// Localize href for one given menu.
if ($link['menu_name'] == 'menu-arborescence') {
   $link['href'] = _i18n_menu_link_href($link['link_path'], $language->language);
}

But it still doesn't work for some items. Besides, it's a crappy solution, of course.

Any new on this ?

tmorgan’s picture

Countzero...
I have the same issue. My solution isn't optimal, but it is working. I have English and Chinese.

I have some pages that exist in English only; some in Chinese only. I do not want users to click the language selector for a language that doesn't exist. English (primary) is not a problem. Everything works fine.

If I set an alias for the Chinese page, I get "file not found" errors. As stated earlier, this is a bug. I should be able to set a URL alias on any page and have it return the correct page pair. It's an alias, yes? So on the backend, the system should be picking up the correct node (as it does for editing) and returning the node but displaying whatever I have set for the alias.

But... here's the odd thing (and it is working)...

On my Chinese page (node/123 or whatever the number is), I did _not_ set a page-level alias for URL Path settings.
I _did_ set the language (in my case Chinese) -- important for blocks that should only display for that language.

Go to Alias settings,
/ Administration / Configuration / Search and metadata » URL aliases
Add an alias for the node
Select : Language => All Languages
Path = node/123
Alias = jian/nihao

The URL now correctly shows the alias, not the node number.

(and the URL path setting on the page shows No Alias)