Hi - first off - great module - came just at the right time for me :)

I'm posting this here, however, feel free to move it to another module.

Basically the problem is this:
The language switcher switches to /langcode/node/xxx rather than /langcode/mypath/myalias when used with i18n for node translation since hook_translation_link_alter returns un-aliased node links.

I don't know whether this is a problem with i18n or a problem in general or specifically a problem with this module and I don't have time right now to check - however it is an easy fix in this module, and arguably this module should perform the aliasing on links given it anyway.

Basically a simple fix.
Take out the check_url(url($path)) at line 52 and add check_url(url($lang_option['href'], array('language' => $lang_option['language'])) at line 71 after translation_link_alter has returned its results.

This also fixes a problem with translated node urls being incorrectly attached to the end of a path alias - i.e.
en/mypathalias/mynodetitle became fr/mypathalias/mynodetitle/node/25

Patch attached.

CommentFileSizeAuthor
lang_dropdown.patch1.26 KBsubspaceeddy

Comments

mohammed j. razem’s picture

Status: Active » Fixed

Thanks for patch! it's committed to the dev snapshot.

You managed to solve a problem that was bothering me when building translation URLs. This is exactly what was needed :)

not_Dries_Buytaert’s picture

Title: urls lose aliased paths when used with i18n » Incorrect and un-aliased URLs when switching language using Switcher Dropdown: {host}/langcode/node/node/nid

Just for the record, I confirm this issue also occurs without the i18n module.

mohammed j. razem’s picture

Priority: Normal » Critical

Status: Fixed » Closed (fixed)

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