I have checked the issue queue and there are a number of issues related to i18n, but I could not find this exact issue. The issues is as follows -
I have a multilingual site - English is the default language (no prefix) and Spanish is the other language (prefix is "es"). I also have Apache Solr search, which does not filter by language by default. Consider that user is in the Spanish site and does a search. All matching nodes from English and Spanish are shown. The urls of the English nodes come as "node/[nid]" i.e. non-aliased. If user clicks a English node title, he is properly redirected to the Spanish translation if the translation of the node is available. Problem is when the English node does not have a translation. Then it leads to a "page not found". I thought this is as per design, but checking the module's code I found that the module actually redirects to the proper node after changing the global $language. So this should work; but it does not. I did some digging in and found that adding the following line after line 161 fixes the issue -
$options['prefix'] = $language->prefix;
Now, question is - am I doing it right, or I have misunderstood or mis-configured something? (Of course I know that I should create a patch rather than editing the module, but want to confirm whether this is really an issue)
Comment | File | Size | Author |
---|---|---|---|
#15 | different_language_redirect-1710156-15.patch | 1.47 KB | m.abdulqader |
| |||
#9 | 1710156-different_language_redirect-09.patch | 1.11 KB | Jose Reyero |
#4 | different_language_redirect-1710156-4.patch | 553 bytes | fabianderijk |
Comments
Comment #1
fabianderijkI've created a patch for this issue
Comment #2
fabianderijkComment #4
fabianderijkReadded the patch with correct working paths
Comment #5
fabianderijkComment #7
fabianderijk4: different_language_redirect-1710156-4.patch queued for re-testing.
Comment #9
Jose Reyero CreditAttribution: Jose Reyero at ESCR-Net commentedI've found a similar issue. The problem seems to happen when trying to redirect to a language that has no prefix.
Example: /es/node/1
The node is English (no prefix) so it should redirect to /node/1
but instead it keeps redirecting (endless loop) to /es/node/1
I've traced the issue to the following lines in locale_language_url_rewrite_url(), which as we can see, if the language to redirect to has no prefix, doesn't override the original one.
This patch fixed the issue for me, it's basically the same as the one proposed by @fabianderijk just bit more generic.
Comment #10
kmontyI had this exact problem and patch #9 solved the issue.
Comment #11
kmontyFurther clarifying title.
Comment #12
kmontyComment #13
BarisW CreditAttribution: BarisW at LimoenGroen commentedThis need more reviewers. Just one reviewer isn't enough to set it to RTBC.
Comment #14
m.abdulqader CreditAttribution: m.abdulqader at Sprintive commentedPatch needs to be rerolled
Comment #15
m.abdulqader CreditAttribution: m.abdulqader at Sprintive commentedComment #16
Simon Georges CreditAttribution: Simon Georges at Makina Corpus commentedI can confirm I had the same issue and this patch fixed it.
Comment #17
i-trokhanenkoPatch #15 fixes redirection issue for me. +1 RTBC
Thanks!