Hi,
I spent huge amount of time figuring out what's going on!. so if you're using i18n module you may experience the same problem.
i18n module catches the url before path_redirect, and because it does not understand it, it simple redirects user to home page!

Solution is to change path_redirect module weight less than i18n module weight which is -10 currently in system table. that would be nice if someone provide the require patch for fixing this issue.

Thanks for sharing this great module :)
Regards

Comments

HorsePunchKid’s picture

Priority: Critical » Normal

Is there a way to do this programmatically? What are the conventions on having modules set their own weight? It seems like everyone would want their module to be first if it weren't regulated in some way.

sinasalek’s picture

There is a module for tweaking weight via admin interface, i didn't use it but i guess that's easier.
And also i think path_redirect module should set its weight less than i18n module when it's installing to become able to catch the urls.

momper’s picture

hello,

weight 20 i18n - blocks 5.x-2.x-dev

weight 0 i18n - menu 5.x-2.x-dev

weight 0 i18n - profile 5.x-2.x-dev

weight 20 i18n - taxonomy 5.x-2.x-dev

weight 0 i18n - views 5.x-2.x-dev

weight -10 Internationalization 5.x-2.x-dev

weight 0 Menutranslation 5.x-1.x-dev

weight 10 Translation 5.x-2.x-dev

this means concret: ideal weight -11 for path redirect?

sorry - there are a lot of different weights of the i18n modules and i'm a little bit confused ...

greetings momper

sinasalek’s picture

The name is exactly "i18n" in name field in Drupal "system" table. but you don't need to be worry about that. give path_redirect -90 for example and you're good to go. path_redirect should be very first module in the list.

momper’s picture

thanks :)

vacilando’s picture

Did change the weight of path_redirect to -90 but still it does not work when i18n is on :-((

DrakeRemory’s picture

Ok, I found the solution. The thing is that path_redirect takes the path from $_SERVER['REQUEST_URI'] which contains for example "en/" at the beginning. Because of this there are no matches in the database. So I added these 3 lines in path_redirect.module on line 36:

if (module_exists('i18n')) {
$path = substr($path, 3);
}

There's no need to change the weight.

Hopefully I could help some of you guys.

sinasalek’s picture

Thanks, hope module developer apply it.

wiert’s picture

for some languages the language code is longer then 2 so:

if (module_exists('i18n')) {
global $locale;
$len = strlen($locale) + 1;
$path = substr($path, $len);
}

I'm not sure however, whether I can simply use the $locale variable or that I have to pull the $node->language variable out first.

sokopok’s picture

Another solution:

In English:
from:
en/content/company
to:
content/company/who

In Dutch:
from
nl/content/bedrijf
to:
content/bedrijf/wie

In Language xxx:
from:
xxx/content/something
to:
content/something-else

2xe’s picture

a comment to sinasalek and wiert:

Your solutions presuppose prefixed URLs, and not the use of domain names. To make the solution generic you must check how the multilanguage support is implemented.

pivica’s picture

Code from #9 will not work for drupal 6. Here is a code for d6:

if (module_exists('i18n')) {
  global $language;
  $len = strlen($language->prefix) + 1;
  $path = substr($path, $len);
}
David Lesieur’s picture

Version: 5.x-1.x-dev » 6.x-1.x-dev
Status: Active » Needs review
StatusFileSize
new1.18 KB

Here's a patch. It has some changes from the above:

  • Don't risk truncating the path if there's no language prefix.
  • No check for i18n. Language prefixes in paths are now a Drupal core feature.

Still, there might be a more fundamental problem to be solved in path_redirect: Under D6, URL aliases have a language field, so should the path redirects to avoid ambiguities.

kehan’s picture

subscribing

dave reid’s picture

Status: Needs review » Needs work

You'll need to check out the latest code (6.x-1.0-beta3) which now officially has multilingual support. The code in your patch has been massively changed.

owen barton’s picture

As far as I can tell this is fixed in the 6.x branch for a regular i18n setups. Someone with domain on prefix-less setups might want to test also before we close.

dave reid’s picture

Status: Needs work » Fixed

I'm going to mark this as fixed for now. I've had a few people test it on multilingual sites and it works for them. This will not be backported to Drupal 5 as it is feature locked.

Status: Fixed » Closed (fixed)

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