Automatic creation of url-aliases always makes the alias language specific. We choose to turn language negotiation off to avoid that multilingual minefield drupal locale and i18n present. But every time a node is updated, pathauto creates an alias restricted to the language of the node it points to, resulting in a page not found when being accessed in a different language. There is no need for this behaviour, since url aliases should be unique anyway. The way it is now, Pathauto only works for multilingual sites with content negotiation on. I consider this to be a bug.

There are three possible solutions.

  1. Pathauto doesn't set a value for language in the alias when language negotiation is turned off
  2. When redirecting, pathauto ignores set language values, when language negotiation is turned off
  3. Users can configure, whether they want an automatic alias with or without language set by Pathauto

Which one do you think would be best?

Hint for everyone encountering the same issue as long as the module isn't fixed: The workaround is to issue an sql command on the database like Update dbprefix_url_alias set language = '' every time a node is updated.

Comments

darkodev’s picture

+1 for a fix.

Same issue with pathauto not showing aliases when not using language negotiation.

Thoughts on the options presented:

#1 would not allow our application to work for all nodes, only those that were recently updated
#2 would work best for us, as it would allow aliases to work if language negotiation were toggled at some point after node creation
#3 would provide most flexibility, but might be more to manage and would require extra UI

darkodev’s picture

This seems to have worked around the issue for us:

function mymodule_nodeapi(&$node, $op, $teaser, $page) {
	switch ($op) {
		case 'update':
		if (variable_get('language_negotiation',null)==0) {
			db_query('update url_alias set language = ""');
			break;
		}
	}
}
greggles’s picture

@dhrgovic - could you provide a patch? http://drupal.org/patch/create

lightnin’s picture

I'm having a similar problem. I need to set pages on my site to English so that translators will have the option to translate them. (The translate option disappears when the language of a page is set to language neutral). However, I want links to English pages to be set to "All" rather than English, so that when the user visits an untranslated page with the language code in the URL, i.e. /fr/About , the English content at /About will be shown. Once a user has translated the page, I need the translated page link to have the same path as the original, but use the new language code. This way when the url /fr/About is visited, it will then lead to the French translated page.

Each time I edit an English page, Drupal updates the link status to English from All, which leads to 404 errors when the page is viewed with a language prefix in the URL - not good.

I don't have pathauto enabled right now, but is there a way to turn it on to make this scenario work? I also want translated pages to take the same path as the original, only with the language setting included. Any ideas would be really appreciated!

darkodev’s picture

Not sure what shape a patch would take. The nodeapi hook is in our own custom module. Unless you're suggesting that the nodeapi hook addition could go in pathauto? Although it works for us, I'm not sure it's a sustainable approach.

I had a quick look at pathauto code, which is where I think this should happen, and couldn't figure out how to disable this functionality during my brief attempt.

greggles’s picture

Component: Code » I18n stuff

Well, if you're not sure where it should be fixed I'm certainly not. I don't really work with i18n much so I rely on others to maintain that part of Pathauto.

ao2’s picture

Hi,

this issue is related to #321848: How to make pathalias enable alias for all languages?. Maybe users subscribed to this one can comment on the approach taken there.

Regards,
Antonio

darkodev’s picture

@greggles, could you suggest who to approach to discuss this i18n/pathauto feature request further?

greggles’s picture

Not really. Freso has done this historically, or drewish.

dave reid’s picture

Category: bug » support
Priority: Critical » Normal
Status: Active » Fixed

If content negotiation is turned off, core's path module still saves URL aliases using $node->language. I don't see how we can fix this problem from without Pathauto. Possibly in D7 you can use a path alter or update hook to change the language of the alias itself.

Status: Fixed » Closed (fixed)

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