Posted by mianwo on November 8, 2007 at 8:27am
| Project: | Internationalization |
| Version: | 5.x-2.2 |
| Component: | Code |
| Category: | feature request |
| Priority: | normal |
| Assigned: | mianwo |
| Status: | closed (won't fix) |
Issue Summary
When you create a multilingle site using i18n module, Sometimes there's more than one URLs linking to the same content.
For example, If your default language is en, and "node/123" is an english page, then both "yousite.com/node/123" and "yousite.com/en/node/123" will point to the same content. This is not a bug but it may confuse some search engines.
So I modified i18n.module by adding following lines to it after line 221(within function i18n_nodeapi):
case 'view':
if($node->language != i18n_get_lang_prefix(_i18n_get_original_path())){
_i18n_goto(i18n_path(i18n_get_normal_path(_i18n_get_original_path()), $node->language));
}
break;This will check for the language of the content and compare it to the language code in the url, if different, the page will be redirected to the url which contains the same language code with the content.
In the above example, if you goto yousite.com/node/123 or yoursite.com/fr/node/123, the page will be redirected to yoursite.com/en/node/123
Comments
#1
I can confirm that the code works as expected. Very good and indeed wanted. +1
I have attached above code as a patch against i18n 5.x-2.x-dev from November 4, 2007.
#2
a different approach to the same problem: http://drupal.org/node/208712
#3
I have added this to the #227550: Patch bundle.
#4
The above code needs to be changed slightly to work with the December 5, 2007, version of 5.x-2.x-dev. See the attached patch.
I also took the liberty to change the category from task to a feature request.
#5
Could someone rewrite these lines of code for the 6.x version, or maybe someone has already done so? I made a feature request to deal with duplicate content urls in i18n (6.x) here #274761: Handling missing translations but it will probably take some time for something to happen, if at all. This would be good to use, otherwise it will be lot's of robots.txt rules :S
#6
Only critical bug fixes for 5.x.