Hello!
I'm rather new to Drupal, so maybe I just miss something - but the behavior I've encountered seems to me quite strange.
So, I've set up a multilanguage site. Let's say, there are two languages: english (en) and russian (ru).
I have a content type "company" with translation enabled. Also I have pathauto installed and all company nodes are aliased to "company/[nid]".
Language negotiation is set to "Domain only", but I suppose with prefixes it won't be any difference.
And now I create view with list of all companies. Since they can be in different languages (ru, en or both) I use "Select translation" filter to show nodes in current language if available and in original otherwise.
So far so good.
Then I add "Node: Title" field to my view and check "Link this field to its node" option. Now if I have node 1 in english and node 2 in russian, I will get following links:
en.example.com/company/1
ru.example.com/company/2
So aliases work great, but if I follow one of these links - interface will switch to the language of the node, and this is undesirable side-effect for me.
On the other hand, if I use "Node: Link" field, I get something different (assuming current lang is english):
en.example.com/node/1
en.example.com/node/2
So, no interface language switch, but unfortunately no aliasing as well. Seems inconsistent or at least confusing.
Actually, what I was trying to get is:
en.example.com/company/1
en.example.com/company/2
After some digging I've figured out that difference is that in the first case Views pass $options['language'] into l() function and in the second it doesn't. And l() function uses this $options['language'] for both language negotiation and language-specific alias lookup. So it's clear why aliasing wasn't working in the second case - since aliases were created for node's original language.
Has someone encountered similar behavior? Are there reasons why it was implemented in this way and how to deal with it?
For now I've just commented out the line which populates $options['language'] and made all my aliases language-independent, but I suppose there should be a better way to do that...
Comments
Hi, I know I'm reviving an
Hi,
I know I'm reviving an old thread here but I have the exact same problem. I have a multilanguage site with a view which contains a node title with the option "Link this field to its node" checked. If I have my interface in let's say Spanish and I browse to my view and click on the node title, I get redirected to the node in English, which is not the behaviour I want...
Anyone found a way to fix this ?
Could it be the node you want
Could it be the node you want to open is an 'old' node?
When you go to the Devel page and you check the variable 'language' than this variable should be empty. When 'en' is mentioned there, it will redirect automatically to the default language.
You should make your content language neutral (that helped for me) and I removed all 'en' references in de database.