Hi, I'm not quite sure where the problem comes from.
I'm using Drupal 7 ,i18n , my nodes are language symmetrical like ge/node/nid = de/node/nid

here's my issue: I've installed LinkIt module that basically provides a UI to easily select internal nodes to link them. the links are provided like "node/nid". Those links then are corrected through an input filter by pathauto. The problem is that pathauto (I'm not sure that pathauto does that) adds a language prefix to the link. The language prefix comes from the currently selected language by the users who edits that particular node, so for example if an German speaking editor edits a node body that contains internal links all of them get converted to de/node/nid, that seems not to be such a big problem but if someone accidentally re saves that node having selected English all of those links will be converted to en/node/nid and as long as those links are cached when someone clears caches having German selected, all of those links throughout the entire website convert pointing de/node/nid

I'v lost quite a lot of time finding out a solution without any result.

CommentFileSizeAuthor
#7 i18n_links-1156720-7.patch379 bytesidflood

Comments

Garrett Albright’s picture

Does this behavior persist when Pathologic is not enabled for the text format you're using? I don't see where Pathologic comes into this.

Jerome F’s picture

Assigned: Unassigned » alexidze

I think I don't understand your problem, but what I know is that when you use internationalization + Path translation + path + pathauto + Translation redirect (which are all the modules you need to have path translations) and the selection method URL, if the content is not translated, but you browse to the page in a foreign language anyways, the url is displayed with langcode/node/nid You just have to translate it, if there's no trnaslation, the page not found is just avoided by Translation redirect, that's why you see the drupal URL instead of the URL rewriting.

in my opinion the key in your issue is:
if someone accidentally re saves that node having selected English

Then edit it and translate it. The best way to go for the moment is to post in english, have english as default language everywherer and translate it.

Garrett Albright’s picture

Assigned: alexidze » Unassigned

Unassigning this so that it shows up for me.

zambrey’s picture

Version: 7.x-1.2 » 7.x-1.x-dev
Assigned: alexidze » Unassigned

Try latest dev release of i18n. It helped in my case.

anon’s picture

Im the maintainer for Linkit and I have also discoverd a problem with pathologic, i18n and linkit 7.x-2.x-dev.

Links are not inserted like /sv/node/1. Pathfilter then adds an extra prefex (sv) to my link.
Can I configure pathologic in some way to not add this extra prefix, or is this a bug?

idflood’s picture

I have a little different issue but I think the origin is the same.

The difference for me is that it happens with links to files (using insert module). The problem appear only on nodes in a language with prefix. The links that are saved are correct absolute paths, but then pathologic seems to add the language prefix which break the url.

edit: found an easy and clean fix I think, patch coming in 5 minutes

idflood’s picture

Component: Miscellaneous » Code
Category: support » bug
Status: Active » Needs review
StatusFileSize
new379 bytes

The fix I propose here is simply to add a language attribute to the url() function in _pathologic_replace(). As stated in the doc:
"If $options['language'] is omitted, the global $language_url will be used. "

So to make it work I only added this to the parameters passed to url():
'language' => FALSE,

reference: http://api.drupal.org/api/drupal/includes--common.inc/function/url

edit: this fix is clearly ok for files but I'm really not sure about internal links and other possibilities. Reviews will tell.

kmare’s picture

idflood, thanx for that patch. It looks like it works for me but I keep getting the following error/notice message:

Notice: Trying to get property of non-object in locale_language_url_rewrite_url() (line 344 of /path/to/site/includes/locale.inc).

I fixed it this way (file: pathologic.module, line 157):

  $url = url(
    $parts['path'],
    array(
      'query' => $qparts,
      'fragment' => isset($parts['fragment']) ? $parts['fragment'] : NULL,
      'absolute' => $absolute,
      'language' => isset($account->language->language) ? $account->language->language : language_default()->language ,
    )
  );

not sure if it's really the proper solution, but at least for now it's working good for me. I'll just need to test it a bit more.

--
Ioannis Panteleakis

kmare’s picture

nevermind, still getting the error/notice :(
I think user_preferred_language() should be used here.

--
Ioannis Panteleakis

SDC’s picture

Check out the patch by ddanier in #36 on http://drupal.org/node/348421 -- solved my image language-prefix problem.

colan’s picture

Issue tags: +i18n

Adding tag.

colan’s picture

Status: Needs review » Closed (duplicate)