Don't know if it's a bug or a feature :)

Worked with pathauto on every page I did until know but in my actual project which is a multilanguage site it seems that pathauto is not able to handle two languages.

I am running german(default) and english. Once I am adding new content in german it generates a path like http://example.com/de/content/mycontent but I get a page not found when entering the path into the addressbar and all links to that content appears like http://example.com/node/6.

If I choose english it works.

If I delete english it works fine for german and the problem disapears. Only if I am running both languages at the same time, one language get screwed up.

Now I am testing adding an additional third language... stay tuned

CommentFileSizeAuthor
#47 path_i18n.patch1.67 KBmkalbere
#57 path_i18n.patch1.68 KBmkalbere
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

AccessiveApps’s picture

i ve figured something more out...

my pathauto settings are

Pattern for all Article paths in German:
de/article/[title-raw]

Pattern for all Article paths in English:
en/article/[title-raw]

Now it seems that a path like http://example.com/de/de/article/whatever is working but the path in the links (node title and everywhere) are looking like this ... http://example.com/de/article/whatever

Do I something wrong?

apaderno’s picture

I have the same issue.
Maybe the pattern set for different languages should not include the prefix for the language.
I think that the pattern for different language is thought to be used in cases where, i.e., the path for English is content/page/[title-raw]; having a different pattern for different languages would allow (in the example case) to use contenuto/pagina/[title-raw] for Italian content.

apaderno’s picture

Category: bug » support

It is like I thought.

I set a different pattern for different languages without to add a prefix for the language, and they worked.
The pattern for a language should be set only when the pattern is translated using words of that language.

I am changing the category to support request as this is not a bug of the module.

AccessiveApps’s picture

hmmm...

I think thats less a support request and more a bug ... because even if I set all used languages the same pattern like http://example.com/article/[title-raw] , the links getting screwed up anyway.

roll over the node title is giving a node/6 ... rolling over the language tags is giving randomized en/article/title-raw or node/6

strange days :)

apaderno’s picture

It's not a bug in the code, but it's an erroneously set module. Not adding the language prefix is the right way to set the module patterns.

What appears in the links is not something done by the module, which simply sets the aliases for some URLs.

lorrisb’s picture

I have the same problem. So, what should we do to fix this?

apaderno’s picture

See the previous comments.

greggles’s picture

There is also the problem in http://drupal.org/node/269877 which is possibly related but not the same.

apaderno’s picture

From the first comment, I would think that this report is not related with the other; deegree said that he uses patterns like en/article/[title-raw] or de/article/[title-raw], and then wondered why the articles are visible at http://example.com/de/de/article/article-title.

AccessiveApps’s picture

got it ... :)

But then I have to say that the whole thing is really confusing for me and others. But thats not the pathauto description. The problem is that i18 says that you have to prefix your stuff to get the right language. And when you set pathauto with this knowledge you do it wrong.

But thanks for clearing that up.

japanitrat’s picture

so this basically means, to get pathauto working with i18n, I have to:

  • disable path prefixes in the i18n configurations
  • add language token to automatic node path generation

?

apaderno’s picture

Title: Path only works for one language i18 » Path only works for one language

If by i18n you mean the Drupal core module that handles the localization of a Drupal-powered site, then no.
I set a multilingual site which uses language prefixes in the URL (not a different domain for each languages), and I didn't include the languages prefixes in the Pathauto patterns. Doing so, the site was working correctly.

If there are any problems, they can be created by the fact path.module doesn't set the alias of a path when there is already a path alias for a different language.

dvinegla’s picture

What about that?

Default path pattern for Example (applies to all Example node types with blank patterns below):

article/[title-raw]

apaderno’s picture

That is the pattern used when the pattern for a language is empty.
In example, if I have enabled the Italian language (supposing it's not the default language) and I put articolo/[title-raw] like pattern for Italian contents, then the used alias would be it/articolo/[title-raw]; if I don't set a pattern for Italian content, then the alias would be it/article/[title-raw].

dvinegla’s picture

#1

Pattern for all Article paths in German:
de/article/[title-raw]

Pattern for all Article paths in English:
en/article/[title-raw]

Is the same pattern for German and English, de/ and en/ is added by i18n, isn't must be defined in pathauto.

#14
in your case use:
Pattern for all Article paths in Italian:
articolo/[title-raw]

Pattern for all Article paths in English:
article/[title-raw]

ikarusweb’s picture

I cant fix that problem.
Pathauto match only the content with the default language but the link to the other translation is /node/3, without pathauto.

how can i fix that? plz help ^^

vthirteen’s picture

could you solve this problem?

NicoDruif’s picture

I ran into (almost) the same problem... but was able to fix it with following settings:

pathauto node settings: [title-raw]
language handling settings: second one, using only path prefix
non-default language prefix setting (in my case English): en

and voila: all previously set (auto)paths worked again, because it now really switches language, thanks to the prefixes on non-default languages!

marvil07’s picture

subscribing

Dave Reid’s picture

Status: Active » Fixed

As pointed out, don't add language prefixes in the Pathauto patterns. That's automatically handled by core's locale.module.

Anonymous’s picture

Status: Fixed » Active

This does not seem fixed, since even without the language tokens in the patterns and NicoDruif's settings, the paths of all translations seem to reset to the system path once I edit one node of a translation set.

Dave Reid’s picture

Status: Active » Postponed (maintainer needs more info)

@xeophin: Please give the exact steps to reproduce this bug.

Iztok’s picture

The problem is that when you set new default language (this is often after some development went by) those alias urls are language specified. So if you post your new content when in German language your URL will be for German only. This is actually silly, because you have disabled languages in your node type.

Ergo: Pathauto should check Node type language settings when creating new alias.

NicoDruif's solutions is not really a solution, it just controls in which language you really are. So if you would be on example.com/en/news you won't get URL aliases for node, because they were inserted by German user (editor) and alias are German, but node is language neutral!

I had this issue just now, because I want to have English enabled (more used to) but I want to add content I need to go to example/sl/node/page if I want that my Slovenian visitors to see URL aliases.

My solution was to disable English language and installed Administration Translate module. Now, even I if I create content by /en/node/add... link I still get alias in my default, non-English language.

Anonymous’s picture

1. Go to a node you want to have translated into another language.
2. Go to translate and choose "Add translation".
3. Enter new content, set Pathauto to set an automatic alias.
4. Submit form.
5. A new alias is for the new node is created. In the same moment, the alias for the original node is replaced with the system path (node/[nid]) (together with Path Redirect, this means that the former alias now redirects to the node/[nid]-path).

Additional steps:

6. Go back to the original node, edit and save: the alias for the original node is created again; but at the same time the alias of the translation is replaced with its system path.

Dave Reid’s picture

Re #24: You would need to switch to the translated node's language in order to view URLs with its alias. The original node's alias was never replaced in my testing and there was never a redirect created. Until I can replicate an actual Pathauto problem with the latest module code, this is still needs more info.

jinkim’s picture

I can reproduce #24.

Let me try to add a bit more detail to steps that reproduces the bug.

Step 1: In Configuration for Languages, set Language Negotiation to Path prefix only.

Step 2: Setup two languages English and Spanish with language codes en and es, respectively, with English as default language

Step 3: Create a content type with multi language option available.

Step 4 In Automated Alias Settings of URL Alias, in Node Path Settings for the content type created in Step 3...

for English
[title-raw]

for Spanish
[title-raw]

This is important setting. Note that there's no difference between English and Spanish settings. There's no language code prefix in the path settings since i18n will add it.

Note that there's nothing else added to the path settings to differentiate the two as in #15 (i.e. no leading articles vs. articulos).

Step 5: Create a new node using the content type from Step 3 with title "Test Article" and set its language to English and URL Alias to auto generate.

Path auto creates an alias for this node http://yourdomain.com/test-article

Step 6: Create a translation of node created in Step 5 with the EXACT SAME TITLE "Test Article" and set its language to Spanish and URL alias to auto generate.

Pathauto creates an alias for the Spanish translation at the same alias as the English node without including the language prefix following the setting set in Step 4. since that's how the setting is done and have setting set in Step 1 takes care of that instead.

The alias is no longer associated with the English node.

It makes sense when you think of it. Autopath is only doing what its being told to do in its settings. But, of course what we want is for it to understand the setting in i18n and add the language code into the aliases that it's creating.

I think if Autopath provided a replacement pattern for getting the path prefix value generated by i18n when Language Negotiation is set would be ideal.

Anonymous’s picture

Thank you for the detailed description, this is exactly what happens.

yustos’s picture

I had the same problem. I configured two languages (English and Russian with language codes en and ru, respectively), with English as default language. The alias was created and my page was accessible from URL http://example.com/en/my-page. But the page would not load from http://example.com/en/my-page address (404 error) if I set default language to Russian. The page would work if I change English language to neutral in the alias list (or if I delete it in a language field of the {url_alias} table ) after translation is created. As the temporary solution I inserted the string "$language == ' en '? $language = ":";" in pathauto.inc after line 217
" else {
$verbose = FALSE;
} "
This forces using English language as a neutral when creating the alias. I do not think, that it is a good solution, but it works.

apaderno’s picture

Status: Postponed (maintainer needs more info) » Active

I am setting back the issue to active, as the required details have been given.

Dave Reid’s picture

Haven't quite determined if this is a pathauto or core bug however.

Gabriel R.’s picture

This problem occurs to me only on one specific content type, but not others.

1. The content type multilingual support is set to ''Disabled''.
2. There is no custom path alias for any content type. The common pattern for content is [type]/[title-raw]

EXPECTED:
- /en/contenttype/title and /fr/contenttype/title to send to the same node.
- All lists to point to the corresponding language specific URL.

RESULT:
- /en/contenttype/title works, while /fr/contenttype/title doesn't
- When the language is /fr/ the node links are in the format /fr/node/123

Desperate.

Gabriel R.’s picture

Guys, I believe this is the same issues as #737562: Language neutral nodes get node/123 paths instead of nice URLs. I spent half a day trying to find the cause, only to discover it is in fact the intended behavior #258785: Provide more flexible settings for initial language on content types

klonos’s picture

Just so that every body knows (trust me I got it working just fine in my site)...

1) Using language prefix in the pathauto replacement patterns is not the right way and doesn't work. So this:

en/[title-raw]
fr/[title-raw]

or this:

en/page/[title-raw]
fr/page/[title-raw]

or this:

en/[type]/[title-raw]
fr/[type]/[title-raw]

... so on...

is a no-go! As noted in earlier posts, prefixes are meant to be handled by the core locale module and that alone.-

2) Prefixes for the default language right now only work when Language negotiation is set to 'Path prefix with language fallback'. I know it should also work with 'Path prefix only', but it doesn't and that is a known core (D6) bug: #269877: path_set_alias() doesn't account for same alias in different languages

To get this fixed you'll need to...

a) switch to 'Path prefix with language fallback' + set a prefix for all languages including the default one.
b) If you are using D6.15 you'll need to apply the patch in post #77 from #358315: drupal_lookup_path() not respects alias' order. Alternatively use D6.16 that has this patch merged.
c) Apply patch from post #146 in #269877: path_set_alias() doesn't account for same alias in different languages

Once the last patch I mention in step c) gets into core, all you'll have to do is use latest drupal (perhaps next 6.17?) + only step a) mentioned above naturally.

That's it! Good luck people and let us know if it worked for you too.

Edit/PS: just in case someone reads this after a long time... in the meantime there might be newer patches in posts after #146 of #77 in their respective issues above. Please always use latest patches of issues mentioned.

klonos’s picture

Is this: #739416: template base_path() code - breaking il8n menu links the same (duplicate) or perhaps related?

blueblade’s picture

Hi klonos,

Thanks for posting the information but unfortunately it didnt work for me. I followed step a and c but skipped b because I am using Drupal 6.16. Pathauto 6.x-1.3 is the version I am usin. Is there anything I might have missed?

Thanks.

BB

klonos’s picture

I don't thing you've missed something in the process I described. The only different thing in my setup is that I use pathauto latest dev, but still I see no reason for that to be a problem. Just to make sure, install latest dev and check again.

blueblade’s picture

Hey Thanks klonos,

Do you mean this version: pathauto 6.x-1.x-dev http://drupal.org/node/95354? This problem seems so impossible to solve. Many thanks to your kind help.

BB

klonos’s picture

Yep! that's the one ;)

try it and if it still doesn't work, come back and I'll see if I can help you troubleshoot this further.

blueblade’s picture

Hi klonos,

Here's the update:

I have just
-installed pathauto 6.x-1.x-dev
-followed step a
-skipped b (I am using Drupal 6.16)
-applied path from step c.

When node is set as 'Language Neutral' or when "Multilingual support" on admin/content/node-type/contenttypename page, those links will work correctly.

Many thanks!!

How ever, node is NOT set as 'Language Neutral' but any other language when "Multilingual support" on admin/content/node-type/contenttypename page is enabled, those links stop working again, for example:

For a node saved with language selected as "English", I will get the correct URL, en/page/xxx, but as soon as I switch the language to another language when viewing the node, I get whateverlanguage/node/xxx (it should be "page" not "node").

If possible I want the users to be able to select the language they are using for the content so that each language is filtered out and I dont get multiple languages showing all on one page....

Do you have any idea how this can be done with pathauto or do you know of any alternative ways to take care of this?

BB

klonos’s picture

What are your settings in admin/build/path/patterns and admin/build/path/settings? Is English set as the default language for your site or Japanese?

You should have [type-name]/[title-raw] as pattern for node paths. Do NOT use language prefixes here (no 'en' or 'ja').

Please delete any other setting and leave only that (only the first field) so we can start from scratch.

After doing the above, try to create a new page and also add a translation to it. Let me know what the paths of these two pages are in the end.

blueblade’s picture

Hi Klonos,

I see no pages as "admin/build/path/pattern" nor "admin/build/path/settings" on my site. Do you mean "admin/build/path" page?

Under "admin/build/path" page > tab "Automated alias settings" > "Node path settings" I have only "Default path pattern for Stories (applies to all Stories node types with blank patterns below):" set as:
users/[author-uid]/stories/[nid]

All other fields are left blank. No language prefixes are used at all.

I did a test and found that using [nid] is NOT the problem. (I have Asian language on my site such as Japanese and I prefer not to use [title-raw], not sure if I am worrying too much tho, what do you think?)

Test 1:
1. Create a story node, select language as "English"
2. URL shown as en/users/1/stories/testcontent-1651
3. Switch to view page in Japanese using language switcher, URL turns to ja/users1/node/1651

Test 2:
1. Create a story node, select language as "Language Neutral"
2. URL shown as en/users/1/stories/testcontent
3. Switch to view page in Japanese using language switcher, URL turns to ja/users/1/stories/testcontent-1651

Test 3 (this is what you expect to happen but slightly different from what I want. I do not want the users to translate their content):
1. Create a story node, select language as "English"
2. URL shown as en/users/1/story/testcontent
2a. translate content into japanese
3. Switch to view page in Japanese using language switcher, URL turns to ja/users/1/stories/testcontent-1651
4. If you have more than two languages enabled. Whatever language is not translated will disappear from the language switch bar

Goal is to let users set language to anything but Language Neutral in Step 1, but still get results as in Test 2 (step 3), I really hope this is possible as without the users setting the language, my site will be a huge mess... Also, I dont expect the users to translate their content, just want them to select the language they're typing.

Thanks again for your kind help.

BB

Freso’s picture

Status: Active » Closed (duplicate)

I'm 99% sure this is a duplicate of #321848: How to make pathalias enable alias for all languages?:

  1. Original issue states that the German alias "de/content/mycontent" doesn't work from English, which is because of the alias language (also related is the fact that they used the language specifier in the alias pattern).
  2. Most recent discussion is a clear duplicate of #321848; "Language Neutral" nodes' alias is properly shown in all languages, while language specific aliases are only shown properly in their own language.

(I'm keeping this in the "support request" category as the original issue was also (in part) to do with a misconfiguration with having the language code in the alias pattern.)

blueblade’s picture

Hi Freso,

Thanks for replying and I apologize for posting duplicated questions. Did you mean that there is actually no fix for the problem? Sorry for being such idiot but I have been a little confused by this. Thanks again for your help.

klonos’s picture

Hey bb, my bad... I meant to explain this, but I always forget. Please use 6.x-2.x-dev found here: http://drupal.org/node/710692 (instead of 6.x-1.x-dev). That's why you don't see the 'patterns' & 'settings' tabs.

Also, you'll need to use the -raw variant of replacements. I have read a very well-explained reason why to do so somewhere in the past few days, but I can't remember where. I was convinced that there are pretty good reasons why though.

Try this and let me know.

blueblade’s picture

Hi Klonos,

Thanks again.

I have just tried out pathauto-6.x-2.x-dev but still get the exact result as I posted here http://drupal.org/node/357185#comment-2796212: URLs are shown correctly when language is set to Language Neutral only. Do you see something else I should check further?

Also, I saw this information on http://drupal.org/node/710692 page about pathauto-6.x-2.x-dev:

In general this branch is not well supported and you should probably upgrade to 7.x-1.x whenever possible.

I hope we don't have to switch to Drupal 7 for this function to work because I see that most modules are not yet ready for Drupal 7. Is there any plan to have this fixed soon for Drupal 6? Please help...Thanks.

BB

blueblade’s picture

Hi again Fresno,

Do you know if the next version of pathauto will take care of the problems you mentioned in #42 (http://drupal.org/node/357185#comment-2796428)? or should we wait till Drupal 7?

Thanks.

BB

mkalbere’s picture

Category: bug » support
FileSize
1.67 KB

To summarize the prob:
node/XX as an alias XXALIAS

When viewing the site in the node/XX language
OK -> the alias is correct

When viewing in an other language
KO -> alias doesn't exist and the link is displayed as LANG/node/XX

Solution :
- When inserting/updating a new alias force the insert for the other languages
Principe of the modifs in path.module :

- db_query("UPDATE {url_alias} SET src = '%s', dst = '%s', language = '%s' WHERE pid = %d", $path, $alias, $language, $pid);
+      foreach (array_keys(language_list('language', TRUE)) as $language)
+        db_query("UPDATE {url_alias} SET src = '%s', dst = '%s', language = '%s' WHERE pid = %d", $path, $alias, $language, $pid);

Attach: patch agaisnt D6.16

Update:
- delete all aliases and recreate them via the bulk update of pathauto

Now All links are aliased, event if the translation doesn't exist ( or if content is only available in neutral language)

Rem: Not deeply tested ..

UPDATE: THIS PATCH IS BUGGED, have a look : on #57

Marko B’s picture

Category: support » bug

I tried everything, patch, different versions and still this module is broken for other langauges.
Did everything said here, even tried on 1.3 1.1 and dev version. Uninstalled module and path module and reinstalled it and its behaving crayze, reporting it crated 50 aliases but when on delete page i have 300 aliases. When i uninstalled module and put it back in, it should have delete all aliases but it didnt they were all there?!

Marko B’s picture

Tried patch #47 and again and all the other setting mention above and maybe in some cases it does work but i dont think its good. Now i get this for six languages

our-services/prices/overnights node/429 English edit delete
our-services/prices/overnights node/429 Italian edit delete
our-services/prices/overnights node/429 All edit delete
our-services/prices/overnights node/429 All edit delete
our-services/prices/overnights node/429 All edit delete
our-services/prices/overnights node/429 All

totaly messed up, too many aliases and still only one working.

Have this patch from 47. language set to prefix with fallaback, latest d6-16, pathauto 1.3. also i am talking about bulk update of paths, this is where it goes wrong.

klonos’s picture

@deepM: did you try what I propose in #33? If not, please do so and report back with your results.

Thanx.

Marko B’s picture

Yes i did exactly that. Problem is that maybe we are talking about 2 different issues altogether. As i was talking about bulk updating URLs most of the time. About plain pathauto when editi/saving nodes, it seems a bit better or at least when i create new node or edit old one usually generates automatic url as defined in pathauto (usint menupath-raw token), its like 50% chance it creates alias, like if i save once it does, then it doesnt if i save it again, than again it does... I just tried it and it happend like that with patches and method you described.
But bulk update is complete mess as i mentioned before in previous posts.

Marko B’s picture

To be more precise, its like 50% working, saved once its ok, second time not ok, third time ok, there must be some bug in patch.

Marko B’s picture

Ok finally found patch that possitivly works and doesnt work 50% with other languages.

Its #62 from http://drupal.org/node/269877#pift-results-269877-1195496-1195496

Tested very much and its working for sure, some other patches made Automatic url alias checkbox dissapear.

klonos’s picture

@deepM: you need to use the latest patch from that issue. It is the one in #146

Marko B’s picture

Said on other place also, think 146 is not good and 62 is.

klonos’s picture

please see my reply in that issue...

mkalbere’s picture

FileSize
1.68 KB

You are right , #47 was buggy.
The aliases where created correctly, but a problem occured on alias update: the correct aliases where overwritten.
I updated my code.

Marko B’s picture

Maybe just leave it to the other post for original update not to confuse people?! what does your patch do that that one doesnt?

mkalbere’s picture

since there was some comment on my last post, I prefered to add it here ...

This patch is an updated version of #47.

Each time a alias is created, it is duplicated for every language

WITH THE PATCH
ex: create for english an alias node/xx -> test
this patch create for all other language exactely the same alias, (FR,IT,DE node/xx -> test), preventing Drupal (function l()) for displaying raw links in menus, blocks etc ...

WITHOUT THE PATCH
When viewing the site, using any other langage (other that the one used to create the alias), raw path are used and you get path like "fr/node/xx" in your menus ..... not very nice

So you will have as many aliases as the number of enabled languages for one single node.

risca’s picture

Category: support » bug

I had the same problem, I've just solve it. Have a look at this patch: is the only solution that I have found (and works)

divined’s picture

v6 and v7

BrianLewisDesign’s picture

Title: Path only works for one language » template base_path() code - breaking il8n menu links

il8n prefix was removed from menu links in my template.php file:

$href = $link['href'] == "<front>" ? base_path() : base_path() . drupal_get_path_alias($link['href']);

Fixed it by sticking $languge->prefix in the path:

global $language;
$prefixx = '';
if ( $language->prefix ) { $prefixx = $language->prefix."/"; }
$href = $link['href'] == "<front>" ? base_path() : base_path() . $prefixx . drupal_get_path_alias($link['href']);

I guess the best way would be to use l() or url()? This worked easily for me in my template.